Skip to content

Commit

Permalink
fix(popover): prevent exiting fullscreen with popover close (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
abugraokkali authored Apr 26, 2023
1 parent 0d0a8c3 commit 2d31e3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/popover/bl-popover.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe('bl-popover', () => {
const popoverEl = body.querySelector('bl-popover') as typeOfBlPopover;
popoverEl.show();

await sendKeys({ up: 'Escape' });
await sendKeys({ down: 'Escape' });

expect(popoverEl.visible).to.equal(false);
});
Expand Down
10 changes: 5 additions & 5 deletions src/components/popover/bl-popover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default class BlPopover extends LitElement {
super.connectedCallback();

this._handlePopoverShowEvent = this._handlePopoverShowEvent.bind(this);
this._handleKeyupEvent = this._handleKeyupEvent.bind(this);
this._handleKeydownEvent = this._handleKeydownEvent.bind(this);
this._handleClickOutside = this._handleClickOutside.bind(this);
}

Expand Down Expand Up @@ -207,7 +207,7 @@ export default class BlPopover extends LitElement {
this.setPopover();
this.onBlPopoverShow('');
document.addEventListener('click', this._handleClickOutside);
document.addEventListener('keyup', this._handleKeyupEvent);
document.addEventListener('keydown', this._handleKeydownEvent);
document.addEventListener('bl-popover-show', this._handlePopoverShowEvent);
}

Expand All @@ -217,7 +217,7 @@ export default class BlPopover extends LitElement {
hide() {
this._visible = false;
document.removeEventListener('click', this._handleClickOutside);
document.removeEventListener('keyup', this._handleKeyupEvent);
document.removeEventListener('keydown', this._handleKeydownEvent);
document.removeEventListener('bl-popover-show', this._handlePopoverShowEvent);
this.onBlPopoverHide('');
}
Expand All @@ -235,10 +235,10 @@ export default class BlPopover extends LitElement {
}
}

private _handleKeyupEvent(event: KeyboardEvent) {
private _handleKeydownEvent(event: KeyboardEvent) {
if (event.key === 'Escape' && this.visible) {
this.hide();
event.preventDefault();
this.hide();
}
}

Expand Down

0 comments on commit 2d31e3c

Please sign in to comment.