Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropdown - Focus/Highlight not visible for sl-menu-items in Safari Browser #2136

Open
dinesh1101 opened this issue Aug 8, 2024 · 3 comments
Labels
bug Things that aren't working right in the library.

Comments

@dinesh1101
Copy link

Describe the bug

Focus/Highlight is not visible in safari for sl-menu-items when pressing down araow after opening the dropdown using click.
But in Chrome browser we can get highlight/focus when we follow the reproducible steps.

To Reproduce

Steps to reproduce the behavior:

  1. Go to sl-dropdown component in safari browser
  2. Click on dropdown to get open
  3. Press down arrow key to have highlight/focus
  4. No highlight/focus happens.

Screenshots

If applicable, add screenshots to help explain the bug.

Browser / OS

  • OS: [Mac]
  • Browser: [Safari]
  • Browser version: [17.5]

Additional information

When interaction happens with keyboard, safari brings the highlight.

  1. Press TAB to get focus for sl-dropdown
  2. Press Enter to open dropdown.
  3. Now Press down arrow key to get highlight/focus.
  4. It will get focus

This highlight/focus will not happen when we open dropdown via click, and then pressing down arrow key.

@dinesh1101 dinesh1101 added the bug Things that aren't working right in the library. label Aug 8, 2024
@CetinSert
Copy link

  1. Open https://shoelace.style/components/menu#in-dropdowns
  2. Click on Edit ▾
  3. Press
  4. No focus outline

image

@CetinSert
Copy link

<sl-menu>s on RTCode.io do not exhibit the same issue 🤔:
image

@KonnorRogers
Copy link
Collaborator

deep long sigh

So this is apparently a fun thing Safari does with :focus-visible.

So apparently if you do element.focus() on "pointerdown", Safari will trigger :focus-visible on a button.

element.focus() in a "click" event, Safari will NOT trigger :focus-visible.

https://blogs.igalia.com/mrego/2021/01/

@CetinSert Yours works because of your pointerenter event.

Here's a rough reproduction of Cetin's:

https://codepen.io/paramagicdev/pen/PorEdgW?editors=1000

Even weirder, you can trigger :focus-visible on your currently focused menu item by hitting right / left arrow keys.

And heres a codepen of the fix:

https://codepen.io/paramagicdev/pen/LYKeJRq

@claviska I think maybe to have consistent behavior, we always call .focus() on pointerdown in sl-button to make it consistent across browsers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Things that aren't working right in the library.
Projects
None yet
Development

No branches or pull requests

3 participants