Repository navigation
fix(core): recompute useMenu defaultOpenKeys when the active resource changes - #7684
Open
shreyanks-1 wants to merge 2 commits into
Open
shreyanks-1 wants to merge 2 commits into
shreyanks-1 wants to merge 2 commits into
Conversation
… changes `defaultOpenKeys` was memoized with an empty dependency array even though it reads `resource` and `resources`, both of which come from the current route. In a persistent sidebar (no remount on navigation), the open keys stayed stuck at whatever resource was active on first render. Added `resource` and `resources` to the dependency array, plus a regression test that navigates between two sibling resources without unmounting and asserts the open keys follow.
🦋 Changeset detectedLatest commit: 03525e8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
Bugs / Features
What is the current behavior?
useMenu'sdefaultOpenKeysis memoized with an empty dependency array, even though it readsresourceandresourcesfromuseResourceParams(). In an app where the sidebar persists across navigation (no remount), navigating between resources does not recomputedefaultOpenKeys— it stays stuck at whichever resource was active on the first render, whileselectedKey(computed the same way, a few lines above) correctly updates.What is the new behavior?
defaultOpenKeys'suseMemonow depends on[resource, resources], so it recomputes whenever the active resource changes. Added a regression test that rendersuseMenuwith a dynamic router mock, navigates from one resource to a sibling resource without unmounting, and assertsdefaultOpenKeysreflects the new resource.fixes #7683
Notes for reviewers
This exact one-line fix was previously proposed in #7543, which received no reviews or comments and was closed without being merged. This PR carries the same fix plus a from-scratch regression test that explicitly exercises a route change without unmounting — the scenario the empty dependency array breaks, and which wasn't covered by any existing test in
useMenu.spec.tsx.