diff --git a/docs/resources/changelog.md b/docs/resources/changelog.md index efebde46c..636bb38e3 100644 --- a/docs/resources/changelog.md +++ b/docs/resources/changelog.md @@ -20,6 +20,7 @@ The docs have been updated to use the new `custom-elements.json` file. If you're - Added `sl-request-close` event to `sl-dialog` and `sl-drawer` - Added `dialog.denyClose` and `drawer.denyClose` animations - Fixed a bug in `sl-color-picker` where setting `value` immediately wouldn't trigger an update +- Fixed a bug in `sl-dialog` and `sl-drawer` where setting `open` intially didn't set a focus trap - Fixed a bug that resulted in form controls having incorrect validity when `disabled` was initially set [#473](https://github.com/shoelace-style/shoelace/issues/473) - Fixed a bug in the docs that caused the metadata file to be requested twice - Updated the docs to use the new `custom-elements.json` for component metadata diff --git a/src/components/dialog/dialog.ts b/src/components/dialog/dialog.ts index 5014ea000..0e78b9bab 100644 --- a/src/components/dialog/dialog.ts +++ b/src/components/dialog/dialog.ts @@ -95,6 +95,11 @@ export default class SlDialog extends LitElement { firstUpdated() { this.dialog.hidden = !this.open; + + if (this.open) { + this.modal.activate(); + lockBodyScrolling(this); + } } disconnectedCallback() { diff --git a/src/components/drawer/drawer.ts b/src/components/drawer/drawer.ts index 5677ad926..33fe6d709 100644 --- a/src/components/drawer/drawer.ts +++ b/src/components/drawer/drawer.ts @@ -112,6 +112,11 @@ export default class SlDrawer extends LitElement { firstUpdated() { this.drawer.hidden = !this.open; + + if (this.open && !this.contained) { + this.modal.activate(); + lockBodyScrolling(this); + } } disconnectedCallback() {