-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
1 parent
7a40af6
commit 07ba551
Showing
9 changed files
with
213 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.