Skip to content

Commit 825e80e

Browse files
committed
fix(core): include scroll button width calulation in showScrollButtons
1 parent 14732b4 commit 825e80e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/pfe-core/controllers/overflow-controller.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ export class OverflowController implements ReactiveController {
4242
}
4343
this.overflowLeft = !this.#hideOverflowButtons && !isElementInView(this.#container, this.firstItem);
4444
this.overflowRight = !this.#hideOverflowButtons && !isElementInView(this.#container, this.lastItem);
45-
this.showScrollButtons = !this.#hideOverflowButtons && (this.overflowLeft || this.overflowRight);
45+
let scrollButtonsWidth = 0;
46+
if (this.overflowLeft || this.overflowRight) {
47+
scrollButtonsWidth = (this.#container.parentElement?.querySelector('button')?.getBoundingClientRect().width || 0) * 2;
48+
}
49+
this.showScrollButtons = !this.#hideOverflowButtons &&
50+
this.#container.scrollWidth > (this.#container.clientWidth + scrollButtonsWidth);
4651
this.host.requestUpdate();
4752
}
4853

0 commit comments

Comments
 (0)