Skip to content

Commit 175a1dc

Browse files
authored
fix: trim CSS custom properties values (#186)
1 parent fbca2b7 commit 175a1dc

File tree

8 files changed

+25
-2
lines changed

8 files changed

+25
-2
lines changed

packages/vaadin-app-layout/src/vaadin-app-layout.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ class AppLayoutElement extends ElementMixin(ThemableMixin(PolymerElement)) {
513513

514514
/** @protected */
515515
_updateOverlayMode() {
516-
const overlay = getComputedStyle(this).getPropertyValue('--vaadin-app-layout-drawer-overlay') == 'true';
516+
const overlay = this._getCustomPropertyValue('--vaadin-app-layout-drawer-overlay') == 'true';
517517
const drawer = this.$.drawer;
518518

519519
if (!this.overlay && overlay) {
@@ -559,9 +559,15 @@ class AppLayoutElement extends ElementMixin(ThemableMixin(PolymerElement)) {
559559
this.drawerOpened = false;
560560
}
561561

562+
/** @private */
563+
_getCustomPropertyValue(customProperty) {
564+
const customPropertyValue = getComputedStyle(this).getPropertyValue(customProperty);
565+
return (customPropertyValue || '').trim().toLowerCase();
566+
}
567+
562568
/** @protected */
563569
_updateTouchOptimizedMode() {
564-
const touchOptimized = getComputedStyle(this).getPropertyValue('--vaadin-app-layout-touch-optimized') == 'true';
570+
const touchOptimized = this._getCustomPropertyValue('--vaadin-app-layout-touch-optimized') == 'true';
565571

566572
const navbarItems = this.querySelectorAll('[slot*="navbar"]');
567573

packages/vaadin-app-layout/test/app-layout.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ describe('vaadin-app-layout', () => {
158158
});
159159

160160
it('should not close on navigation event when not in overlay mode', () => {
161+
// force it to desktop layout
162+
layout.style.setProperty('--vaadin-app-layout-drawer-overlay', 'false');
163+
layout._updateOverlayMode();
161164
layout.drawerOpened = true;
162165
window.dispatchEvent(new CustomEvent('vaadin-router-location-changed'));
163166
expect(layout.drawerOpened).to.be.true;

packages/vaadin-app-layout/test/visual/lumo/app-layout.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ describe('app-layout', () => {
4141
element.primarySection = 'drawer';
4242
await visualDiff(div, `app-layout:${dir}-primary-drawer`);
4343
});
44+
45+
it('overlay', async () => {
46+
// See https://github.com/vaadin/vaadin-app-layout/issues/183
47+
element.style.setProperty('--vaadin-app-layout-drawer-overlay', ' true');
48+
window.dispatchEvent(new Event('resize'));
49+
await visualDiff(div, `app-layout:${dir}-overlay`);
50+
});
4451
});
4552
});
4653
});

packages/vaadin-app-layout/test/visual/material/app-layout.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ describe('app-layout', () => {
4141
element.primarySection = 'drawer';
4242
await visualDiff(div, `app-layout:${dir}-primary-drawer`);
4343
});
44+
45+
it('overlay', async () => {
46+
// See https://github.com/vaadin/vaadin-app-layout/issues/183
47+
element.style.setProperty('--vaadin-app-layout-drawer-overlay', ' true');
48+
window.dispatchEvent(new Event('resize'));
49+
await visualDiff(div, `app-layout:${dir}-overlay`);
50+
});
4451
});
4552
});
4653
});
8.63 KB
Loading
8.61 KB
Loading
8 KB
Loading
8.01 KB
Loading

0 commit comments

Comments
 (0)