Skip to content

Commit

Permalink
fix: Wrong pageId used for segment navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
hetunandu committed Dec 19, 2024
1 parent 80f4739 commit 194f2ec
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions app/client/src/pages/Editor/IDE/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import { closeJSActionTab } from "actions/jsActionActions";
import { closeQueryActionTab } from "actions/pluginActionActions";
import { getCurrentBasePageId } from "selectors/editorSelectors";
import { getCurrentEntityInfo } from "../utils";
import { useEditorType } from "ee/hooks";
import { useParentEntityInfo } from "ee/hooks/datasourceEditorHooks";

export const useCurrentEditorState = () => {
const [selectedSegment, setSelectedSegment] = useState<EditorEntityTab>(
Expand Down Expand Up @@ -60,9 +58,7 @@ export const useCurrentEditorState = () => {
export const useSegmentNavigation = (): {
onSegmentChange: (value: string) => void;
} => {
const editorType = useEditorType(location.pathname);
const { parentEntityId: baseParentEntityId } =
useParentEntityInfo(editorType);
const basePageId = useSelector(getCurrentBasePageId);

/**
* Callback to handle the segment change
Expand All @@ -74,17 +70,17 @@ export const useSegmentNavigation = (): {
const onSegmentChange = (value: string) => {
switch (value) {
case EditorEntityTab.QUERIES:
history.push(queryListURL({ baseParentEntityId }), {
history.push(queryListURL({ basePageId }), {
invokedBy: NavigationMethod.SegmentControl,
});
break;
case EditorEntityTab.JS:
history.push(jsCollectionListURL({ baseParentEntityId }), {
history.push(jsCollectionListURL({ basePageId }), {
invokedBy: NavigationMethod.SegmentControl,
});
break;
case EditorEntityTab.UI:
history.push(widgetListURL({ baseParentEntityId }), {
history.push(widgetListURL({ basePageId }), {
invokedBy: NavigationMethod.SegmentControl,
});
break;
Expand Down

0 comments on commit 194f2ec

Please sign in to comment.