Skip to content

Commit

Permalink
Close the overlay on detach. Fixes #54
Browse files Browse the repository at this point in the history
  • Loading branch information
manolo committed Feb 27, 2018
1 parent 974dc3d commit 5c39aa9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/vaadin-dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@
this.$.overlay.addEventListener('vaadin-overlay-escape-press', this._handleEscPress.bind(this));
}

disconnectedCallback() {
super.disconnectedCallback();
this.opened = false;
}

_openedChanged(opened) {
if (opened && !this._instance) {
this._contentTemplate = this.querySelector('template');
Expand Down
5 changes: 5 additions & 0 deletions test/vaadin-dialog_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
expect(overlay.getAttribute('role')).to.be.eql('dialog');
});

it('overlay should close on dettach', () => {
dialog.parentNode.removeChild(dialog);
expect(dialog.opened).to.eql(false);
});

describe('no-close-on-esc', () => {
it('should close itself on ESC press by default', () => {
MockInteractions.pressAndReleaseKeyOn(document.body, 27, [], 'Escape');
Expand Down

0 comments on commit 5c39aa9

Please sign in to comment.