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

[Bug]: Combobox input field excessive focus/blur events. #1500

Closed
JarvisH opened this issue Dec 17, 2024 · 1 comment
Closed

[Bug]: Combobox input field excessive focus/blur events. #1500

JarvisH opened this issue Dec 17, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@JarvisH
Copy link

JarvisH commented Dec 17, 2024

Environment

- MacOS Chrome 131.0.6778.140
- Radix version 1.9.11

Link to minimal reproduction

https://stackblitz.com/edit/jkiw2fdl?file=src%2FApp.vue

Steps to reproduce

Add focus/blur events to ComboboxInput

Describe the bug

When using the keyboard to navigate the items inside a Combobox, the highlighted item is briefly focussed followed by the input field being focussed:

// ComboboxRoot.vue
onInputNavigation: async (val) => {
    ...

    // Option is briefly focussed
    focusOnSelectedElement()

    // Focus is returned to input field
    nextTick(() => inputElement.value?.focus({ preventScroll: true }))
  },

The explanation in focusOnSelectedElement reads:

// Find the highlighted element and focus
// This helps the screen readers to read the selected value

I am not well-versed in screen-readers, but is this really necessary? I would assume, that aria-selected would serve this purpose. I briefly tested this using the MacOS VoiceOver utility, and here it made no difference, but maybe there are screen-readers which need the focus to occur?

The issue caused by this is simply excessive blur/focus events on the input field, which is not a huge deal, but it would be nice to fix it nonetheless.

Expected behavior

Blur/focus events are not triggered when navigating the list.

Context & Screenshots (if applicable)

No response

@JarvisH JarvisH added the bug Something isn't working label Dec 17, 2024
@zernonia
Copy link
Member

Yo @JarvisH . Thanks for the issue.
Yeah we need to have focusOnSelectedElement behaving as such due to certain browser not behave as expected with aria-activedescendant.

Will close this issue for now as it doesn't really incur bug for the user 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants