Revan0809 opened a new pull request, #700:
URL: https://github.com/apache/shenyu-dashboard/pull/700

   ## Summary
   `SiderMenu` cached `this.flatMenuKeys` in the constructor and never rebuilt 
it when the `menuData` prop changed later (e.g. plugin or permission menus that 
populate asynchronously, or a namespace change introducing new routes). 
`getSelectedMenuKeys()` kept matching against the stale array, so a newly-added 
route could render in the menu but never show as selected/highlighted when 
navigated to.
   
   `getDefaultCollapsedSubMenus` (used for the open-keys calculation in 
`getDerivedStateFromProps`) already recomputed a fresh flat-key array from 
`nextProps.menuData` on every prop change — it just wasn't also updating the 
cached `this.flatMenuKeys` field that `getSelectedMenuKeys()` relied on.
   
   - Removed the `this.flatMenuKeys` instance field entirely.
   - `getSelectedMenuKeys()` now derives flat keys from `this.props.menuData` 
on every call, matching the pattern already used for open-keys.
   
   Fixes #642
   
   ## Test plan
   - [x] Added a regression test 
(`src/components/SiderMenu/SilderMenu.test.js`) that constructs a `SiderMenu` 
with an initial `menuData`, then simulates an async menu update (mimicking 
props changing after construction) and asserts `getSelectedMenuKeys()` 
correctly matches the newly-added route — `7/7` tests pass
   - [x] Verified the new test actually catches the bug: reverting the fix 
while keeping the test reproduces the exact failure described in the issue 
(`getSelectedMenuKeys()` returns `[]` instead of the newly-added route's keys)
   - [x] `npx eslint --ext .js src/components/SiderMenu/SiderMenu.js 
src/components/SiderMenu/SilderMenu.test.js` — no new issues (pre-existing 
CRLF/prettier warnings on this Windows checkout are unrelated and present 
repo-wide, confirmed absent from the actual diff)
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to