Skip to content

Commit ac3551e

Browse files
authored
fix: hide dialog when hidden is applied (#9866)
* fix: hide dialog when hidden is applied * simplify selectors
1 parent 2cc42b7 commit ac3551e

File tree

6 files changed

+38
-27
lines changed

6 files changed

+38
-27
lines changed

packages/confirm-dialog/src/vaadin-confirm-dialog.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,16 @@ class ConfirmDialog extends ConfirmDialogMixin(ElementMixin(ThemePropertyMixin(P
7272

7373
static get styles() {
7474
return css`
75-
:host,
76-
[hidden] {
77-
display: none !important;
78-
}
79-
8075
:host([opened]),
8176
:host([opening]),
8277
:host([closing]) {
8378
display: contents !important;
8479
}
80+
81+
:host,
82+
:host([hidden]) {
83+
display: none !important;
84+
}
8585
`;
8686
}
8787

packages/confirm-dialog/test/confirm-dialog.test.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,23 @@ describe('vaadin-confirm-dialog', () => {
3131
confirm = fixtureSync('<vaadin-confirm-dialog></vaadin-confirm-dialog>');
3232
});
3333

34-
it('should enforce display: none to hide the host element', () => {
35-
confirm.style.display = 'block';
34+
it('should use display: none when not opened', () => {
3635
expect(getComputedStyle(confirm).display).to.equal('none');
3736
});
3837

3938
['opened', 'opening', 'closing'].forEach((state) => {
40-
it(`should enforce display: contents when ${state} attribute is set`, () => {
41-
confirm.style.display = 'block';
39+
it(`should use display: contents when ${state} attribute is set`, () => {
4240
confirm.setAttribute(state, '');
4341
expect(getComputedStyle(confirm).display).to.equal('contents');
4442
});
4543
});
44+
45+
it('should use display: none when hidden while opened', async () => {
46+
confirm.opened = true;
47+
confirm.hidden = true;
48+
await nextRender();
49+
expect(getComputedStyle(confirm).display).to.equal('none');
50+
});
4651
});
4752

4853
describe('properties', () => {

packages/crud/src/vaadin-crud-dialog.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,16 @@ class CrudDialog extends DialogBaseMixin(OverlayClassMixin(ThemePropertyMixin(Po
9797

9898
static get styles() {
9999
return css`
100-
:host,
101-
[hidden] {
102-
display: none !important;
103-
}
104-
105100
:host([opened]),
106101
:host([opening]),
107102
:host([closing]) {
108103
display: contents !important;
109104
}
105+
106+
:host,
107+
:host([hidden]) {
108+
display: none !important;
109+
}
110110
`;
111111
}
112112

packages/dialog/src/vaadin-dialog.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,16 @@ class Dialog extends DialogSizeMixin(
102102

103103
static get styles() {
104104
return css`
105-
:host,
106-
[hidden] {
107-
display: none !important;
108-
}
109-
110105
:host([opened]),
111106
:host([opening]),
112107
:host([closing]) {
113108
display: contents !important;
114109
}
110+
111+
:host,
112+
:host([hidden]) {
113+
display: none !important;
114+
}
115115
`;
116116
}
117117

packages/dialog/test/dialog.test.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,23 @@ describe('vaadin-dialog', () => {
3131
await nextRender();
3232
});
3333

34-
it('should enforce display: none to hide the host element', () => {
35-
dialog.style.display = 'block';
34+
it('should use display: none when not opened', () => {
3635
expect(getComputedStyle(dialog).display).to.equal('none');
3736
});
3837

3938
['opened', 'opening', 'closing'].forEach((state) => {
40-
it(`should enforce display: contents when ${state} attribute is set`, () => {
41-
dialog.style.display = 'block';
39+
it(`should use display: contents when ${state} attribute is set`, () => {
4240
dialog.setAttribute(state, '');
4341
expect(getComputedStyle(dialog).display).to.equal('contents');
4442
});
4543
});
44+
45+
it('should use display: none when hidden while opened', async () => {
46+
dialog.opened = true;
47+
dialog.hidden = true;
48+
await nextRender();
49+
expect(getComputedStyle(dialog).display).to.equal('none');
50+
});
4651
});
4752

4853
describe('opened', () => {

packages/rich-text-editor/src/vaadin-rich-text-editor-popup.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ class RichTextEditorPopup extends PolylitMixin(LitElement) {
3232

3333
static get styles() {
3434
return css`
35-
:host {
36-
display: none !important;
37-
}
38-
3935
:host([opened]),
4036
:host([opening]),
4137
:host([closing]) {
4238
display: contents !important;
4339
}
40+
41+
:host,
42+
:host([hidden]) {
43+
display: none !important;
44+
}
4445
`;
4546
}
4647

0 commit comments

Comments
 (0)