Skip to content

Fix Safari bug closing subnav without following link#284

Draft
chrishow wants to merge 1 commit into
cferdinandi:mainfrom
chrishow:safari-subnav-fix
Draft

Fix Safari bug closing subnav without following link#284
chrishow wants to merge 1 commit into
cferdinandi:mainfrom
chrishow:safari-subnav-fix

Conversation

@chrishow

@chrishow chrishow commented Apr 8, 2026

Copy link
Copy Markdown

Closes #282

Description

On Safari, clicking links inside the subnav closed the menu but prevented link navigation.

Safari's blur event sets relatedTarget to null when clicking links, unlike Chrome which sets it to the clicked element.

This meant the original relatedTarget check couldn't determine that focus was moving to a link inside the nav, causing the subnav to close immediately without giving Safari a chance to follow the link.

Changes

blur event handler skips closing subnavs with the data-navigating flag via :not([data-navigating]) selector

Added mousedown and click event handlers to detect link clicks before blur events fire:

  • mousedown: Sets a temporary data-navigating flag on the details element
  • click: Removes the data-navigating flag and closes the subnav after navigation starts

Kelp Contributor License Agreement

I give Chris Ferdinandi and Go Make Things, LLC permission to license my contributions on any terms they like. I am giving them this license in order to make it possible for them to accept my contributions into their project.

As far as the law allows, my contributions come as is, without any warranty or condition, and I will not be liable to anyone for any damages related to this software or this license, under any kind of legal claim.

@chrishow

chrishow commented Apr 8, 2026

Copy link
Copy Markdown
Author

I've left this as a draft PR because it increases the complexity of this component quite a lot. Perhaps someone has a better approach?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Subnav web component doesn't work in Safari

1 participant