Skip to content

fix(TopNav): stop click propagation on heading links in mixed mode - #2135

Merged
josephfarina merged 1 commit into
mainfrom
navi/fix/topnav-heading-click-propagation
May 11, 2026
Merged

fix(TopNav): stop click propagation on heading links in mixed mode#2135
josephfarina merged 1 commit into
mainfrom
navi/fix/topnav-heading-click-propagation

Conversation

@josephfarina

Copy link
Copy Markdown
Contributor

Problem

When XDSTopNavHeading has both headingHref and menu props (mixed mode), clicking the logo or heading text inconsistently triggers navigation. Sometimes it opens the menu instead.

Root Cause

In mixed mode, the root <div> receives triggerProps.onClick from useXDSMenuHover which toggles the popover. Clicks on the logo LinkComponent and heading text LinkComponent bubble up to this handler, causing the menu to toggle instead of (or alongside) navigating.

The chevron button already had e.stopPropagation() — the link elements were just missing it.

Fix

Add onClick={e => e.stopPropagation()} to all link elements rendered inside the mixed-mode trigger div:

  • Logo LinkComponent
  • Heading text LinkComponent
  • Superheading XDSLink
  • Subheading XDSLink

This ensures link clicks navigate cleanly without triggering the menu popover.

Repro

<XDSTopNavHeading
  logo={<MyLogo />}
  headingHref="/"
  menu={<NavMenu />}
/>

Click the logo rapidly — sometimes it navigates, sometimes the menu opens instead.

When XDSTopNavHeading has both headingHref and menu (mixed mode), the root
div receives triggerProps.onClick which toggles the menu popover. Clicks on
the logo link and heading text link bubble up to this handler, causing the
menu to toggle instead of (or in addition to) navigating. This makes the
link click work inconsistently.

Fix: add onClick stopPropagation to all link elements rendered inside the
mixed-mode trigger div (logo LinkComponent, heading LinkComponent,
superheading XDSLink, subheading XDSLink). The chevron button already had
this — the links were just missing it.
@vercel

vercel Bot commented May 11, 2026

Copy link
Copy Markdown

@josephfarina must be a member of the Meta Open Source team on Vercel to deploy.
- Click here to add @josephfarina to the team.
- If you initiated this build, request access.

Learn more about collaboration on Vercel and other options here.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label May 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 18.3KB 28.3KB 4.2KB

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@josephfarina
josephfarina merged commit e2734f6 into main May 11, 2026
19 of 20 checks passed
@josephfarina
josephfarina deleted the navi/fix/topnav-heading-click-propagation branch May 11, 2026 23:18
cixzhang pushed a commit that referenced this pull request Jun 21, 2026
…2135)

When XDSTopNavHeading has both headingHref and menu (mixed mode), the root
div receives triggerProps.onClick which toggles the menu popover. Clicks on
the logo link and heading text link bubble up to this handler, causing the
menu to toggle instead of (or in addition to) navigating. This makes the
link click work inconsistently.

Fix: add onClick stopPropagation to all link elements rendered inside the
mixed-mode trigger div (logo LinkComponent, heading LinkComponent,
superheading XDSLink, subheading XDSLink). The chevron button already had
this — the links were just missing it.
cixzhang pushed a commit that referenced this pull request Jun 21, 2026
…2135)

When XDSTopNavHeading has both headingHref and menu (mixed mode), the root
div receives triggerProps.onClick which toggles the menu popover. Clicks on
the logo link and heading text link bubble up to this handler, causing the
menu to toggle instead of (or in addition to) navigating. This makes the
link click work inconsistently.

Fix: add onClick stopPropagation to all link elements rendered inside the
mixed-mode trigger div (logo LinkComponent, heading LinkComponent,
superheading XDSLink, subheading XDSLink). The chevron button already had
this — the links were just missing it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant