diff --git a/.changeset/native-dialog-backdrop.md b/.changeset/native-dialog-backdrop.md new file mode 100644 index 000000000..bb9ff8a51 --- /dev/null +++ b/.changeset/native-dialog-backdrop.md @@ -0,0 +1,6 @@ +--- +"@tabler/core": minor +"@tabler/preview": minor +--- + +Added `dialog::backdrop` styling so a native `` uses the same backdrop as modals. diff --git a/.changeset/scroll-chaining-contain.md b/.changeset/scroll-chaining-contain.md new file mode 100644 index 000000000..c251d7493 --- /dev/null +++ b/.changeset/scroll-chaining-contain.md @@ -0,0 +1,5 @@ +--- +"@tabler/core": patch +--- + +Added `overscroll-behavior: contain` to `.modal`, `.modal-body`, `.offcanvas-body` and `.dropdown-menu-scrollable`. diff --git a/core/scss/ui/_dropdowns.scss b/core/scss/ui/_dropdowns.scss index 073eae57f..0bcef4b45 100644 --- a/core/scss/ui/_dropdowns.scss +++ b/core/scss/ui/_dropdowns.scss @@ -62,6 +62,7 @@ height: auto; max-height: $dropdown-scrollable-height; overflow-x: hidden; + overscroll-behavior: contain; } .dropdown-menu-column { diff --git a/core/scss/ui/_modals.scss b/core/scss/ui/_modals.scss index d32bfc754..bd6ea8905 100644 --- a/core/scss/ui/_modals.scss +++ b/core/scss/ui/_modals.scss @@ -16,6 +16,7 @@ .modal-body { @include scrollbar(); + overscroll-behavior: contain; .modal-title { margin-bottom: var(--modal-body-title-margin-bottom); @@ -74,7 +75,25 @@ --modal-body-title-margin-bottom: #{$modal-body-title-margin-bottom}; --modal-footer-padding-y: #{$modal-footer-padding-y}; + overscroll-behavior: contain; + @include media-print() { display: none !important; } } + +// +// Native dialog +// +// Make the backdrop of a native `` opened with `showModal()` match the +// backdrop used by modals and offcanvases. +// +// The alpha is part of the color instead of `opacity`, so that `backdrop-filter` +// blurs the page instead of blending a blurred copy over the sharp one. +dialog::backdrop { + background: color-mix(in sRGB, var(--backdrop-bg) calc(var(--backdrop-opacity) * 100%), transparent); +} + +dialog.modal-blur::backdrop { + backdrop-filter: var(--backdrop-filter); +} diff --git a/core/scss/ui/_offcanvas.scss b/core/scss/ui/_offcanvas.scss index 85a3ab68d..17f83aedb 100644 --- a/core/scss/ui/_offcanvas.scss +++ b/core/scss/ui/_offcanvas.scss @@ -6,6 +6,10 @@ } } +.offcanvas-body { + overscroll-behavior: contain; +} + .offcanvas-header { border-bottom: var(--border-width) var(--border-style) var(--border-color); } diff --git a/preview/pages/modals.astro b/preview/pages/modals.astro index e1b74d90d..a49bb7ef6 100644 --- a/preview/pages/modals.astro +++ b/preview/pages/modals.astro @@ -2,6 +2,9 @@ // Every modal is rendered inline via ModalInline (in place, unlike Modal.astro // which drains to ). import DefaultLayout from '@shared/layouts/DefaultLayout.astro' +import CaptureScript from '@shared/components/CaptureScript.astro' +import Button from '@ui/Button.astro' +import ButtonList from '@ui/ButtonList.astro' import Card from '@ui/Card.astro' import CardBody from '@ui/CardBody.astro' import ModalInline from '@shared/components/modals/ModalInline.astro' @@ -52,6 +55,7 @@ const cardClass = 'position-relative rounded d-block bg-surface-backdrop py-6 w- Confirm delete modal Change password modal Add task modal + Native dialog
@@ -158,9 +162,59 @@ const cardClass = 'position-relative rounded d-block bg-surface-backdrop py-6 w-
+ + +
+

The browser keeps the page behind this dialog inert, traps focus inside it and closes it on Esc.

+
+ + +
+ + + + + + +