Skip to content

Commit 0195c84

Browse files
committed
space calculation fix
1 parent c18980f commit 0195c84

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

packages/core/src/components/select/select.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,10 @@ export class Select
293293
private readonly chipWidths = new Map<string, number>();
294294
private readonly overflowChipRef = makeRef<HTMLElement>();
295295
private readonly chipsContainerRef = makeRef<HTMLElement>();
296+
private readonly clearButtonRef = makeRef<HTMLElement>();
296297

297298
private readonly chipHorizontalMargin = 4;
298-
private readonly triggerMinWidth = 48;
299+
private readonly triggerMinWidth = 78;
299300
private readonly overflowChipFallbackWidth = 52;
300301
private overflowChipWidth = 0;
301302
private chipsResizeObserver?: ResizeObserver;
@@ -1170,7 +1171,12 @@ export class Select
11701171
return;
11711172
}
11721173

1173-
const available = container.clientWidth - this.triggerMinWidth;
1174+
const clearButtonWidth =
1175+
this.allowClear && this.clearButtonRef.current
1176+
? this.clearButtonRef.current.offsetWidth
1177+
: 0;
1178+
const available =
1179+
container.clientWidth - this.triggerMinWidth - clearButtonWidth;
11741180
if (this.canShowAllChips(values, available)) {
11751181
this.applyOverflowState(null, []);
11761182
return;
@@ -1477,6 +1483,7 @@ export class Select
14771483
variant="subtle-tertiary"
14781484
oval
14791485
size="16"
1486+
ref={this.clearButtonRef}
14801487
onClick={(e) => {
14811488
e.preventDefault();
14821489
e.stopPropagation();

0 commit comments

Comments
 (0)