Skip to content

Commit

Permalink
Select label width adjustment (#843)
Browse files Browse the repository at this point in the history
* select label width adjustment

* Fix label with ellipses

* Fix changeset

* Addd comment

---------

Co-authored-by: Paweł Chyła <[email protected]>
  • Loading branch information
Cloud11PL and poulch authored Aug 27, 2024
1 parent a6348a8 commit 6a51f52
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/early-planets-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@saleor/macaw-ui": patch
---

You can now see ellipses in select when text width is too long.
2 changes: 1 addition & 1 deletion src/components/Combobox/Common/ComboboxWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const ComboboxWrapper = forwardRef<
{...getLabelProps({ htmlFor: id })}
cursor={disabled ? "not-allowed" : "text"}
>
<Box display="flex" flexDirection="column" __width="79%">
<Box display="flex" flexDirection="column" width="100%">
<Box
as="span"
className={classNames(spanRecipe({ typed, size, disabled, error }))}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Combobox/Static/StaticCombobox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export const WithAdornment = () => {

export const WithEllipsis = () => {
const values = [
{ value: "color-black", label: "Long black label here" },
{ value: "color-black", label: "Very very long black label here" },
{
value: "color-red",
label: "Long red label here",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Select/Select.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export const WithStartAdornment = () => {

export const WithEllipsis = () => {
const values = [
{ value: "color-black", label: "Long black label here" },
{ value: "color-black", label: "Very very long black label here" },
{
value: "color-red",
label: "Long red label here",
Expand Down
13 changes: 4 additions & 9 deletions src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,16 @@ const SelectInner = <T extends Option, V extends Option | string>(
getLabelProps={getLabelProps}
getToggleButtonProps={getToggleButtonProps}
>
<Box
height={getBoxHeight(size)}
{...props}
ref={ref}
whiteSpace="nowrap"
overflow="hidden"
textOverflow="ellipsis"
display="flex"
>
<Box height={getBoxHeight(size)} {...props} ref={ref} display="flex">
{startAdornment && typed && startAdornment(value)}
<Text
size={convertSizeToScale(size)}
color={labelColor}
title={selectedItem?.label}
width="100%"
whiteSpace="nowrap"
overflow="hidden"
textOverflow="ellipsis"
>
{selectedItem?.label}
</Text>
Expand Down
7 changes: 6 additions & 1 deletion src/components/Select/SelectWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ export const SelectWrapper = forwardRef<HTMLLabelElement, SelectWrapperProps>(
data-macaw-ui-component="Select"
cursor={disabled ? "not-allowed" : "pointer"}
>
<Box display="flex" flexDirection="column" __width="79%">
<Box
display="flex"
flexDirection="column"
// Take full width minus the arrow icon width
__width="calc(100% - 30px)"
>
<Box
as="span"
className={classNames(
Expand Down

0 comments on commit 6a51f52

Please sign in to comment.