Skip to content

Commit

Permalink
fix(core): overflow controller resize loop (#2855)
Browse files Browse the repository at this point in the history
* fix(core): add requestAnimation to resizeObserver  on overflow controller

* chore(core): add changeset

* fix(core): replace checks, reduce overhead

Co-authored-by: Benny Powers - עם ישראל חי! <[email protected]>

* chore(core): update changeset to correct change level

Co-authored-by: Benny Powers - עם ישראל חי! <[email protected]>

* chore(core): update changeset language

Co-authored-by: Benny Powers - עם ישראל חי! <[email protected]>

* test(tabs): add nextFrame to test given addtional requestAnimationFrame in overflow

---------

Co-authored-by: Benny Powers - עם ישראל חי! <[email protected]>
  • Loading branch information
zeroedin and bennypowers authored Sep 25, 2024
1 parent 366d21d commit 0ec7338
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/fluffy-bananas-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@patternfly/pfe-core": patch
---

`OverflowController`: prevent browser from locking up in some scenarios
4 changes: 3 additions & 1 deletion core/pfe-core/controllers/overflow-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export class OverflowController implements ReactiveController {
});

#ro = new ResizeObserver(() => {
this.#setOverflowState();
requestAnimationFrame(() => {
this.#setOverflowState();
});
});

showScrollButtons = false;
Expand Down
3 changes: 1 addition & 2 deletions elements/pf-tabs/test/pf-tabs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,10 @@ describe('<pf-tabs>', function() {
});

beforeEach(nextFrame);
beforeEach(updateComplete);
beforeEach(nextFrame);
beforeEach(nextFrame);
beforeEach(updateComplete);


it('should have visible scroll buttons if overflowed', function() {
// Note: overflow buttons are not included in the accessibility tree otherwise we'd test
// for buttons there. tabindex="-1" is used on the buttons to prevent focus and was a
Expand Down

0 comments on commit 0ec7338

Please sign in to comment.