Skip to content

Fix: Redirection to dashboard#1029

Merged
mohdsayed merged 10 commits into
release/v0.13.1from
fix/sidebar-redirection
Apr 4, 2025
Merged

Fix: Redirection to dashboard#1029
mohdsayed merged 10 commits into
release/v0.13.1from
fix/sidebar-redirection

Conversation

@mayan-000

@mayan-000 mayan-000 commented Apr 3, 2025

Copy link
Copy Markdown
Collaborator

Description

This PR fixes the redirection bug.

Problem Statement

We encountered unexpected navigation behavior in the sidebar due to reloads and URL updates:

  1. Sidebar navigation resets unexpectedly:

    • Some sidebar items (e.g., Help Center) trigger a URL update that reloads the entire tab.
    • This causes frames to reload, React re-renders the logic, and if no frame was selected before reload, the sidebar unexpectedly redirects back to the Dashboard page as a fallback to the frame’s null value.
  2. Blank screen issue after reopening the DevTools:

    • If a frame was selected, and a link was clicked on the same host, then upon closing & reopening the DevTools, no sidebar item is selected, resulting in a blank right panel.
    • This happens when the previously selected frame was not found in the newly loaded frames array, leaving the sidebar without a valid selection.
  3. Selected frame not rendering after reload:

    • If the DevTools remain open and the extension reloads, the frames load again, but if the previously selected frame is missing, the UI keeps showing the Cookies landing page, while the sidebar fails to show any selected item.

Solution Approach

To fix this, we are removing the problematic side effect in the logic that caused unintended navigation:

  • Remove the automatic navigation to the Cookies landing page when:
    1. No frame is selected before a reload.
    2. A frame was selected but was not present in the new frames array, which mistakenly triggered the Dashboard page to render.

This prevents unexpected redirection to the Cookies landing page.

To address the remaining issues (2) and (3), we update the sidebar logic:

  • New Sidebar Logic:
    • If a previously selected frame is missing from the newly loaded frames array, instead of leaving the UI in an inconsistent state, we explicitly search for the Cookies landing page in the panel and select it as the fallback.

This ensures that the UI remains consistent without blank screens while maintaining the correct navigation behavior.

Relevant Technical Choices

  • Removes the logic for fallback to the dashboard panel if selectedFrame is null.
  • Adds logic to the sidebar for trying ancestors' panel if current key is not applicable.

Testing Instructions

Additional Information:

Screenshot/Screencast


Checklist

  • I have thoroughly tested this code to the best of my abilities.
  • I have reviewed the code myself before requesting a review.
  • This code is covered by unit tests to verify that it works as intended.
  • The QA of this PR is done by a member of the QA team (to be checked by QA).

Fixes #

@mayan-000 mayan-000 marked this pull request as ready for review April 3, 2025 10:18
@mohdsayed

Copy link
Copy Markdown
Collaborator

@mayan-000 Test failing

Comment thread packages/design-system/src/components/sidebar/useSidebar/provider.tsx Outdated
@mohdsayed mohdsayed added this to the v0.13.1 milestone Apr 4, 2025
@mayan-000 mayan-000 force-pushed the fix/sidebar-redirection branch from 05a9cfb to a10f1bc Compare April 4, 2025 12:20
@mohdsayed mohdsayed merged commit 4f376cf into release/v0.13.1 Apr 4, 2025
@mohdsayed mohdsayed deleted the fix/sidebar-redirection branch April 4, 2025 17:36
This was referenced Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants