Add Dialog.Backdrop
and Dialog.Panel
components
#1333
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Update: Since merging this PR we've realized
Dialog.Backdrop
is unnecessary and we consider it deprecated and won't be including it in the documentation. Since we didn't realize this until a couple of hours after the v1.6 release, we're leaving it in to not break semantic versioning, but it will be removed whenever we eventually do a v2.0.This PR adds 2 new components:
Dialog.Backdrop
(React),DialogPanel
(Vue)Dialog.Panel
(React),DialogPanel
(Vue)The
Dialog.Backdrop
will replace theDialog.Overlay
in a backwards compatible way, because theDialog.Overlay
will still be available.What does this solve?
If you have a
Dialog
with a lot of content, then you want to scroll theDialog
, however in a lot of usage implementations theDialog.Overlay
gets in the way, and you will only be able to scroll with your mouse while it's over the panel itself (the typical white area in the center of your screen). You usually can't scroll the overlay (the gray area) so that is not good.In addition, the scrollbar is typically hidden by the
Dialog.Overlay
, so if your users use the scrollbar itself, they can either not reach it because the overlay sits on top of it, or they can't click it to drag up/down because theDialog
will then close.To fix those problems, we introduced a
Dialog.Backdrop
, this is very similar to theDialog.Overlay
, but there is a technical difference, it will be rendered in a portal as a sibling of theDialog
, not as a child of theDialog
. This fixes the scrolling issues. We created a new component to guarantee backwards compatibility, otherwise this would be a breaking change because now the component will be rendered in a different spot in the DOM.This introduces another issue, the "outside click" behaviour is now technically broken. Because in most cases you are not clicking outside the
Dialog
component because they are typically rendered in "full screen" (especially if you use the Tailwind UI dialogs). To fix this, theDialog.Overlay
had a click listener to close theDialog
, but this newDialog.Backdrop
replacement is now rendered in a different spot and you can't even click it in most cases. To solve this issue we introduced aDialog.Panel
where you can mark that typical white box in the middle of the screen and if you click outside of that box, theDialog
will close.There is also a hard dependency between the
Dialog.Backdrop
and theDialog.Panel
. If you start using the newDialog.Backdrop
then you have to use theDialog.Panel
as well to guarantee that all features keep working as they did before.Upgrade example:
React
Vue
Fixes: #1056
Fixes: #1132