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

Incorrect tab selectedIndex after reordering existing tabs #2131

Closed
livwvil opened this issue Dec 29, 2022 · 1 comment · Fixed by #2145
Closed

Incorrect tab selectedIndex after reordering existing tabs #2131

livwvil opened this issue Dec 29, 2022 · 1 comment · Fixed by #2145
Assignees

Comments

@livwvil
Copy link

livwvil commented Dec 29, 2022

What package within Headless UI are you using?

@headlessui/react

What version of that package are you using?

v1.7.7

What browser are you using?

Chrome

Reproduction URL

https://codesandbox.io/s/headless-ui-tabs-order-issue-g9p9i2?file=/src/App.js

  1. See all tabs looks great and have correct indexes (tab0 - 0, tab1 - 1, tab2 - 2)
  2. Reorder tabs, for example, reverse tabs array
  3. Look at tabs indexes, they are still the same as the first time (tab2 - 2, tab1 - 1, tab0 - 0) but should be another (tab2 - 0, tab1 - 1, tab2 - 2)

Describe your issue

When dynamically reorder tabs in tab list internal lib logic uses initial indexes for tabs. Looks like it is not correct.

@RobinMalfait RobinMalfait self-assigned this Jan 3, 2023
RobinMalfait added a commit that referenced this issue Jan 4, 2023
This will guarantee that when you are using your arrow keys that the
previous / next values are the correct ones instead of the "old" values
before the order change happened.

Fixes: #2131
RobinMalfait added a commit that referenced this issue Jan 4, 2023
* detect change in `Tab` order

This will guarantee that when you are using your arrow keys that the
previous / next values are the correct ones instead of the "old" values
before the order change happened.

Fixes: #2131

* update changelog
@RobinMalfait
Copy link
Member

Hey! Thank you for your bug report!
Much appreciated! 🙏

This should be fixed by #2145, and will be available in the next release.

You can already try it using:

  • npm install @headlessui/react@insiders.
  • npm install @headlessui/vue@insiders.

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.

2 participants