Skip to content

Commit 0658f2c

Browse files
committed
1798: Fixing primary-detail resize listener so it only runs with width changes
1 parent dda9bd0 commit 0658f2c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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)