Skip to content

Commit 2ef7a71

Browse files
committed
fix: update resizing logic to avoid flickering
1 parent b5ccea1 commit 2ef7a71

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/component/vcf-breadcrumbs.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ export class VcfBreadcrumbs extends ResizeMixin(ElementMixin(ThemableMixin(Polyl
9595
* - The first breadcrumb remains fully visible and does not shrink.
9696
*/
9797
_updateBreadcrumbs() {
98+
// Remove existing ellipsis elements before recalculating
99+
this.querySelectorAll('[part="ellipsis"]').forEach((el) => el.remove());
100+
98101
// Get all breadcrumbs elements
99102
const breadcrumbs = Array.from(this.children) as HTMLElement[];
100103

@@ -122,19 +125,16 @@ export class VcfBreadcrumbs extends ResizeMixin(ElementMixin(ThemableMixin(Polyl
122125
firstBreadcrumb.style.minWidth = 'auto';
123126

124127
// Get available space in the container
125-
const containerWidth = this.clientWidth;
128+
const containerWidth = this.getClientRects()[0].width;
126129

127130
// Calculate total width of all breadcrumbs
128-
let totalWidth = breadcrumbs.reduce((sum, item) => sum + item.offsetWidth, 0);
131+
let totalWidth = breadcrumbs.reduce((sum, item) => sum + item.getClientRects()[0].width, 0);
129132

130133
// Find collapse ranges
131134
const collapseRanges = this._findCollapseRanges(breadcrumbs);
132135

133-
// Remove existing ellipsis elements before recalculating
134-
this.querySelectorAll('[part="ellipsis"]').forEach((el) => el.remove());
135-
136136
// If space is very limited, handle collapsing logic
137-
if (totalWidth > containerWidth) {
137+
if (totalWidth > (containerWidth + 1)) {
138138
collapseRanges.forEach(({ start }) => {
139139
const collapseItem = breadcrumbs[start];
140140

0 commit comments

Comments
 (0)