headlessui icon indicating copy to clipboard operation
headlessui copied to clipboard

TabGroup's onChange occurs when data list changes

Open helloheesu opened this issue 1 year ago • 0 comments

What package within Headless UI are you using?

@headlessui/react

What version of that package are you using?

v2.2.0

What browser are you using?

Arc on Mac

Reproduction URL

https://codesandbox.io/p/devbox/6qfgh2

Describe your issue

Please check the above reproduction URL.

Given assumtion:

  • spaces are given which will be tab header list
  • spaces could be updated from outside
  • selectedSpaceId will also be given and could be changed from outside

What I wanted:

When I click 'up' or 'down' button to update spaces, I wanted to keep that space focused, just moved the order.

The problem:

even though I didn't updated selectedSpaceId or selectedIndex, <TabGroup />'s onChange occurs and gives its old selectedIndex. I think its behavior feels more like defaultSelectedIndex than selectedIndex compared to any other controlled form components from other libraries, (i.e. react's text input component).

helloheesu avatar Nov 20 '24 04:11 helloheesu