From 8ec314f2334e3955fcd273f7afd9aa56c9f36ebc Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Thu, 19 Dec 2024 12:18:48 +0530 Subject: [PATCH] fix: Wrong pageId used for segment navigation (#38247) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description > [!TIP] > _Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team)._ > > _Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR._ Fixes #38216 ## Automation /ok-to-test tags="@tag.Git, @tag.IDE" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: 194f2ec70ff59c89f80410ee0088f16372decaa7 > Cypress dashboard. > Tags: `@tag.Git, @tag.IDE` > Spec: >
Thu, 19 Dec 2024 06:19:57 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **New Features** - Enhanced navigation management in the editor for improved user experience. - Streamlined retrieval of the base entity ID for navigation purposes. - **Bug Fixes** - Improved consistency in widget selection behavior based on current focus entity and keyboard events. --- app/client/src/pages/Editor/IDE/hooks.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/client/src/pages/Editor/IDE/hooks.ts b/app/client/src/pages/Editor/IDE/hooks.ts index 25f724ef5f..c6cb404b91 100644 --- a/app/client/src/pages/Editor/IDE/hooks.ts +++ b/app/client/src/pages/Editor/IDE/hooks.ts @@ -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( @@ -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 @@ -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;