Truncate dropdown value (#602)

* truncate dropdown value

* more defensive programming for width
This commit is contained in:
Red J Adaya
2024-04-25 13:36:11 -07:00
committed by GitHub
parent 35037ac1f1
commit 12e267ad81
+9 -2
View File
@@ -258,7 +258,11 @@ class Dropdown extends React.Component<DropdownProps, DropdownState> {
document.getElementById("app")!
)
: null;
let selectedOptionLabelStyle = {};
const wrapperClientWidth = this.wrapperRef.current?.clientWidth;
if ((wrapperClientWidth ?? 0) > 0) {
selectedOptionLabelStyle["width"] = Math.max(wrapperClientWidth - 55, 0);
}
return (
<div
className={cn("wave-dropdown", className, {
@@ -284,7 +288,10 @@ class Dropdown extends React.Component<DropdownProps, DropdownState> {
</div>
</If>
<div
className={cn("wave-dropdown-display unselectable", { "offset-left": decoration?.startDecoration })}
className={cn("wave-dropdown-display unselectable truncate", {
"offset-left": decoration?.startDecoration,
})}
style={selectedOptionLabelStyle}
>
{selectedOptionLabel}
</div>