Skip to content

fix(theme): close the local nav outline dropdown when the link text is clicked - #5536

Open
MFA-G wants to merge 1 commit into
vuejs:mainfrom
MFA-G:fix/outline-dropdown-close-on-text-click
Open

MFA-G wants to merge 1 commit into
vuejs:mainfrom
MFA-G:fix/outline-dropdown-close-on-text-click

Conversation

@MFA-G

@MFA-G MFA-G commented Oct 14, 2026 •

Copy link
Copy Markdown

Description

Since #5437, outline link text is wrapped in <bdi>. When you click the text in the local nav "On this page" dropdown, e.target is the <bdi>, not the .outline-link anchor. That makes onItemClick()'s classList.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 that aria-expanded returns to false and that the hash is updated.

  • Without the fix: fails (expected 'true' to be 'false')
  • With the fix: passes in dev mode and with VITE_TEST_BUILD=1
  • Full e2e suite (dev): 77 passed / 5 skipped
  • pnpm test:unit: 515 passed
  • pnpm typecheck and prettier check: clean

…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
@github-actions github-actions Bot added the stale label Nov 15, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Local navigation outline dropdown does not reliably close after selecting a heading

1 participant