Skip to content

Commit

Permalink
Revert "Move keydown handler for sl-drawer back to base div (#1459)"
Browse files Browse the repository at this point in the history
This reverts commit 1e243e4.
  • Loading branch information
claviska committed Jul 18, 2023
1 parent 8267968 commit f954233
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/components/drawer/drawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ export default class SlDrawer extends ShoelaceElement {
lockBodyScrolling(this);
}
}
// If there is an autofocus element, let it take focuse normally, otherwise focus the panel.
if (!this.querySelector('[autofocus]')) {
this.panel.focus({ preventScroll: true });
}
}

disconnectedCallback() {
Expand All @@ -147,14 +143,14 @@ export default class SlDrawer extends ShoelaceElement {
}

private addOpenListeners() {
this.drawer.addEventListener('keydown', this.handleKeyDown);
document.addEventListener('keydown', this.handleDocumentKeyDown);
}

private removeOpenListeners() {
this.drawer.removeEventListener('keydown', this.handleKeyDown);
document.removeEventListener('keydown', this.handleDocumentKeyDown);
}

private handleKeyDown = (event: KeyboardEvent) => {
private handleDocumentKeyDown = (event: KeyboardEvent) => {
if (this.open && !this.contained && event.key === 'Escape') {
event.stopPropagation();
this.requestClose('keyboard');
Expand Down Expand Up @@ -311,7 +307,6 @@ export default class SlDrawer extends ShoelaceElement {
'drawer--rtl': this.localize.dir() === 'rtl',
'drawer--has-footer': this.hasSlotController.test('footer')
})}
@keydown=${this.handleKeyDown}
>
<div part="overlay" class="drawer__overlay" @click=${() => this.requestClose('overlay')} tabindex="-1"></div>
Expand Down

0 comments on commit f954233

Please sign in to comment.