Files
headlessui/packages/@headlessui-react
Robin Malfait 4f8c615245 Fix incorrect active option in the Listbox/Combobox component (#1264)
* update tests to expose bug in React implementation

* fix incorrect `active` state on mouseLeave

The React code had a bug in the Listbox and Combobox components where it
incorrectly made the first selected value the active value.

The first selected option should be the active option when you open the
listbox. However when you already had the component in an `open` state,
hovered over a non-selected item and them left the option by moving it
to the body then the first selected option became the active one again.

This made sense because we used a `useEffect` in each option to make it
the active one if it was also selected. Since every component
re-renders, code got called and the bug arises.

Now, instead we moved the logic to make it the active option to the
reducer logic. We will check it when we register an option and doesn't
have an active option index yet or when we open the Listbox/Combobox.

This should also solve the strange scrolling behaviour where the options
scroll up if you have more options than you display.

* update changelog
2022-03-21 18:32:49 +01:00
..
2022-01-31 00:10:06 +01:00
2022-01-31 12:29:27 +01:00
2022-03-09 11:24:45 +01:00

@headlessui/react

A set of completely unstyled, fully accessible UI components for React, designed to integrate beautifully with Tailwind CSS.

Total Downloads Latest Release License

Installation

# npm
npm install @headlessui/react

# Yarn
yarn add @headlessui/react

Documentation

For full documentation, visit headlessui.dev.

Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Discuss Headless UI on GitHub

For casual chit-chat with others using the library:

Join the Tailwind CSS Discord Server