Commit a4a0ea5
Ensure we are not freezing data when the
This PR fixes an issue where a listbox with the `static` option had a
delayed `selected` value.
This was happening because of 2 reasons:
1. The `isSelected` function had stale data
2. We use a "frozen value", but we shouldn't do that when the listbox
options are using the `static` option.
The frozen data is used to prevent UI jumps when you have transitions.
For example, if you fade out the listbox when closing then if you select
an option the selected state (and a checkmark for example) would move
around to the newly selected option while the listbox is fading out. To
prevent that we "freeze" the selected value until the listbox is fully
closed. This behaves the same as a native select element.
Fixes: #3778
## Test plan
Tested the fix with the reproduction from the issue:
https://github.com/user-attachments/assets/fbbc2ec3-321b-4e66-b0fc-df5a483dfbba
---------
Co-authored-by: Jordan Pittman <thecrypticace@gmail.com>static prop is used (#3779)1 parent 2de2779 commit a4a0ea5
File tree
3 files changed
+19
-5
lines changed- packages/@headlessui-react
- src/components
- combobox
- listbox
3 files changed
+19
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1332 | 1332 | | |
1333 | 1333 | | |
1334 | 1334 | | |
1335 | | - | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
1336 | 1339 | | |
1337 | 1340 | | |
1338 | 1341 | | |
1339 | 1342 | | |
1340 | 1343 | | |
1341 | 1344 | | |
1342 | | - | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
1343 | 1349 | | |
1344 | 1350 | | |
1345 | 1351 | | |
| |||
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
629 | 629 | | |
630 | 630 | | |
631 | 631 | | |
632 | | - | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
633 | 636 | | |
634 | 637 | | |
635 | 638 | | |
636 | 639 | | |
637 | | - | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
638 | 644 | | |
639 | 645 | | |
640 | 646 | | |
| |||
0 commit comments