Repository navigation
Conversation
…s clicked The outline link text is wrapped in <bdi>, so a click on the text targets the <bdi> rather than the .outline-link anchor and the dropdown stayed open. Match the anchor with closest() instead. fixes vuejs#5533
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.
Description
Since #5437, outline link text is wrapped in
<bdi>. When you click the text in the local nav "On this page" dropdown,e.targetis the<bdi>, not the.outline-linkanchor. That makesonItemClick()'sclassList.contains('outline-link')check fail, so the dropdown doesn't close after navigation. It only closed when the click landed on the anchor's padding.The fix matches the anchor with
(e.target as Element).closest('.outline-link'). That works for clicks on the anchor and on anything inside it.Linked Issues
fixes #5533
Additional Context
There's a new e2e case in
__tests__/e2e/frontmatter/multiple-levels-outline.test.ts. At a 960px viewport it opens the local nav dropdown, clicks the<bdi>of an entry, and asserts thataria-expandedreturns tofalseand that the hash is updated.expected 'true' to be 'false')VITE_TEST_BUILD=1pnpm test:unit: 515 passedpnpm typecheckand prettier check: clean