Skip to content

Commit f4c11aa

Browse files
committed
simplify frozen checks
We don't have to know whether we are transitioning or not. Because we will always freeze the value in single value mode.
1 parent 24227f8 commit f4c11aa

File tree

1 file changed

+2
-3
lines changed
  • packages/@headlessui-react/src/components/listbox

1 file changed

+2
-3
lines changed

packages/@headlessui-react/src/components/listbox/listbox.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,16 +591,15 @@ function OptionsFn<TTag extends ElementType = typeof DEFAULT_OPTIONS_TAG>(
591591

592592
// The moment we picked a value in single value mode, the value should be
593593
// frozen immediately.
594-
let hasFrozenValue = useSlice(machine, machine.selectors.hasFrozenValue) && transition
594+
let hasFrozenValue = useSlice(machine, machine.selectors.hasFrozenValue)
595595

596596
// We should freeze when the listbox is visible but "closed". This means that
597597
// a transition is currently happening and the component is still visible (for
598598
// the transition) but closed from a functionality perspective.
599599
//
600600
// When the `static` prop is used, we should never freeze, because rendering
601601
// is up to the user.
602-
let shouldFreeze =
603-
(hasFrozenValue || (visible && listboxState === ListboxStates.Closed)) && !props.static
602+
let shouldFreeze = hasFrozenValue && !props.static
604603

605604
// Frozen state, the selected value will only update visually when the user re-opens the <Listbox />
606605
let frozenValue = useFrozenData(shouldFreeze, data.value)

0 commit comments

Comments
 (0)