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

defaultHighlightedIndex will select disabled items #1584

Closed
jsvossen opened this issue Mar 22, 2024 · 1 comment · Fixed by #1587
Closed

defaultHighlightedIndex will select disabled items #1584

jsvossen opened this issue Mar 22, 2024 · 1 comment · Fixed by #1587

Comments

@jsvossen
Copy link

jsvossen commented Mar 22, 2024

  • downshift version: 9.0.0
  • node version: 18.18.2
  • npm (or yarn) version: 9.8.1

Relevant code or config

useCombobox({
    isItemDisabled: () => true,
    defaultHighlightedIndex: 0,
    ...
})

What you did:

Set defaultHighlightedIndex={0} with items that are disabled.

What happened:

The disabled item is automatically highlighted, and can be selected by pressing enter.

Reproduction repository:

https://codesandbox.io/p/sandbox/determined-euler-jllv45

Problem description:

defaultHighlightedIndex should not be able to select items that are disabled.

Suggested solution:

Check isItemDisabled before applying highlighted styles or returning the selected item.

@jsvossen
Copy link
Author

jsvossen commented May 1, 2024

Thanks for the fix, but we're still seeing issues with disabled items getting selected. #1587 fixed selected items on open, but if you start typing and the list filters, the first item is still getting highlighted and is selectable by pressing enter.
downshift-bug
https://codesandbox.io/p/sandbox/determined-euler-jllv45?file=%2Fsrc%2Findex.tsx%3A19%2C58

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 a pull request may close this issue.

1 participant