diff --git a/docs/resources/changelog.md b/docs/resources/changelog.md index 21098a0f2..46ca13791 100644 --- a/docs/resources/changelog.md +++ b/docs/resources/changelog.md @@ -11,6 +11,7 @@ New versions of Shoelace are released as-needed and generally occur when a criti ## Next - Fixed a bug that prevented `hoist` from working correctly in `` after updating Floating UI [#1024](https://github.com/shoelace-style/shoelace/issues/1024) +- Fixed a bug in `` that caused containing dialogs, drawers, etc. to close when pressing Escape while focused [#1024](https://github.com/shoelace-style/shoelace/issues/1024) ## 2.0.0-beta.84 diff --git a/src/components/dropdown/dropdown.ts b/src/components/dropdown/dropdown.ts index a72347fa2..13651784f 100644 --- a/src/components/dropdown/dropdown.ts +++ b/src/components/dropdown/dropdown.ts @@ -214,7 +214,8 @@ export default class SlDropdown extends ShoelaceElement { handleTriggerKeyDown(event: KeyboardEvent) { // Close when escape or tab is pressed - if (event.key === 'Escape') { + if (event.key === 'Escape' && this.open) { + event.stopPropagation(); this.focusOnTrigger(); this.hide(); return;