Skip to content

Commit 96afdf7

Browse files
authored
1798: Fixing primary-detail resize listener so it only runs with width changes (#1799)
1 parent dda9bd0 commit 96afdf7

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

CHANGELOG-1.x.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
- [HASH](#URL) fix: Update primary-detail resize listener so it only runs with width changes
2+
13
# 1.11.2 (2021-09-29)
24

35
- [ac2af8](https://github.com/patternfly/patternfly-elements/commit/ac2af8367c911af5b7cb3953eff470106c48b93b) fix: mobile-typography demo page now has correct CSS variables

elements/pfe-primary-detail/src/pfe-primary-detail.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ class PfePrimaryDetail extends PFElement {
153153
this._detailsBackButton = this.shadowRoot.getElementById("details-wrapper__back");
154154

155155
this._debouncedSetBreakpoint = null;
156+
this._windowInnerWidth;
156157

157158
// @todo: decide if we need this anymore
158159
// Store all focusable element types in variable
@@ -302,6 +303,11 @@ class PfePrimaryDetail extends PFElement {
302303
* Then manage state of component and manage active/inactive elements
303304
*/
304305
_setBreakpoint() {
306+
// We don't need to do anything if the page width is unchanged
307+
if (this._windowInnerWidth === window.innerWidth) {
308+
return;
309+
}
310+
305311
const breakpointWas = this.breakpoint;
306312
const breakpointIs = this.offsetWidth < this.breakpointWidth ? "compact" : "desktop";
307313

@@ -344,6 +350,8 @@ class PfePrimaryDetail extends PFElement {
344350
this._setDetailsNavVisibility(false);
345351
}
346352
}
353+
354+
this._windowInnerWidth = window.innerWidth;
347355
}
348356

349357
/**

0 commit comments

Comments
 (0)