fix: restore access token hash navigation - #877
Open
alloutflo wants to merge 1 commit into
Open
Conversation
Signed-off-by: Florian Meyer <fflorian.meyer@outlook.com>
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.
Summary
#access-tokensfragment and later hash changesRoot cause
The existing Next.js links already target
#access-tokens, and the target section already has that ID. However, the section lives in the client-rendered, data-dependentAccessTokenManagementcomponent. The browser can process the fragment before that component is mounted, and there was no client-side handler to retry the scroll once the target existed or when the hash changed later.Fix
useHashScrollchecks the current fragment after the component mounts, subscribes tohashchange, scrolls only when the requested target matches, and removes the listener on unmount. It runs directly insideAccessTokenManagement, so the target element is present when the initial effect runs. The existingnext/linkdestinations remain unchanged.Validation
npm test -- --runInBand src/hooks/useHashScroll.test.ts— 4 focused tests passednpm test -- --runInBand— 35 tests across 8 suites passednpx tsc --noEmit --pretty false— passedwatch()compatibility warning inAccessTokenManagementgit diff --check, including both new files — passedThe repository-wide lint baseline remains red with 97 errors and 19 warnings in pre-existing code; the changed paths introduce no new lint errors. A production build could not complete in the constrained local environment because the build exhausted the available disk space (ENOSPC); it stopped without a
BUILD_IDand without a code-related diagnostic. Playwright was not run because its authenticated stack was not available within that resource limit. No browser or human validation is claimed.AI assistance
AI assistance was used for issue analysis, implementation, and test drafting. The diff and the automated checks listed above were inspected locally; no manual browser validation is claimed.
Fixes l3montree-dev/devguard#2802