Files
headlessui/packages/@headlessui-react/src/components
Robin Malfait 07ba551e63 Add transition prop to DialogPanel and DialogBackdrop components (#3309)
* add internal `ResetOpenClosedProvider`

This will allow us to reset the `OpenClosedProvider` and reset the
"boundary". This is important when we want to wrap a `Dialog` inside of
a `Transition` that exists in another component that is wrapped in a
transition itself.

This will be used in let's say a `DisclosurePanel`:

```tsx
<Disclosure>              // OpenClosedProvider
  <Transition>
    <DisclosurePanel>     // ResetOpenClosedProvider
      <Dialog />          // Can safely wrap `<Dialog />` in `<Transition />`
    </DisclosurePanel>
  </Transition>
</Disclosure>
```

* use `ResetOpenClosedProvider` in `PopoverPanel` and `DisclosurePanel`

* add `transition` prop to `<Transition>` component

This prop allows us to enabled / disable the `Transition` functionality.
E.g.: expose the underlying data attributes.

But it will still setup a `Transition` boundary for coordinating the
`TransitionChild` components.

* always wrap `Dialog` in a `Transition` component

+ add `transition` props to the `Dialog`, `DialogPanel` and `DialogBackdrop`

This will allow us individually control the transition on each element,
but also setup the transition boundary on the `Dialog` for coordination
purposes.

* improve dialog playground example

* update built in transition playground example to use individual transition props

* speedup example transitions

* Add validations to DialogFn

This technically means most or all of them can be removed from InternalDialog but we can do that later

* Pass `unmount={false}` from the Dialog to the wrapping transition

* Only wrap Dialog in a Transition if it’s not `static`

I’m not 100% sure this is right but it seems like it might be given that `static` implies it’s always rendered.

* remove validations from `InternalDialog`

Already validated by `Dialog` itself

* use existing `usesOpenClosedState`

* reword comment

* remove flawed test

The reason this test is flawed and why it's safe to delete it:

This test opened the dialog, then clicked on an element outside of the
dialog to close it and prove that we correctly focused that new element
instead of going to the button that opened the dialog in the first
place.

This test used to work before marked the rest of the page as `inert`.
Right now we mark the rest of the page as `inert`, so running this in a
real browser means that we can't click or focus an element outside of
the `dialog` simply because the rest of the page is inert.

The reason it fails all of a sudden is that the introduction of
`<Transition>` around the `<Dialog>` by default purely delays the
mounting just enough to record different elements to try and restore
focus to.

That said, this test clicked outside of a dialog and focused that
element which can't work in a real browser because the element can't be
interacted with at all.

* update changelog

---------

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2024-06-21 00:44:12 +02:00
..
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2024-05-03 09:55:02 -04:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2024-05-03 09:55:02 -04:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00