Skip to content

(Custom)SelectControl: Truncate long options#43301

Merged
mirka merged 3 commits intotrunkfrom
fix/select-overflow
Aug 17, 2022
Merged

(Custom)SelectControl: Truncate long options#43301
mirka merged 3 commits intotrunkfrom
fix/select-overflow

Conversation

@mirka
Copy link
Copy Markdown
Member

@mirka mirka commented Aug 17, 2022

Fixes #43098

What?

Truncate long option strings in SelectControl/CustomSelectControl.

Why?

The components look broken without it.

How?

With standard string-truncating CSS.

Testing Instructions

Can be tested in either Storybook or WP.

Storybook

  1. npm run storybook:dev
  2. In a SelectControl/CustomSelectControl story, add a width to a wrapper div so the options overflow.

WP

  1. npm run dev
  2. In the editor, add a "Post Date" block.
  3. In the Inspector for that block, see the Typography panel section and add a Font Family (SelectControl) and an Appearance (CustomSelectControl) component. Select a long option to make the text overflow.

✅ Tested with width: fit-content on the container
✅ Tested in Chrome/Firefox/Safari

Screenshots or screencast

image

@mirka mirka added [Type] Bug An existing feature does not function as intended [Package] Components /packages/components labels Aug 17, 2022
@mirka mirka requested a review from ajitbohra as a code owner August 17, 2022 06:09
@mirka mirka self-assigned this Aug 17, 2022
@mirka mirka force-pushed the fix/select-overflow branch from f596245 to e316d46 Compare August 17, 2022 06:12
width: 100%;
max-width: none;
cursor: pointer;
overflow: hidden;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why we're using raw CSS instead of the Truncate component? (I'm ok with both, just curious)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is a placement that works in this case with the <select>. The main reason though is for encapsulating the styles within the styled Select export so it can be reused in CustomSelectControl.

Copy link
Copy Markdown
Contributor

@ciampo ciampo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@mirka mirka merged commit f23244e into trunk Aug 17, 2022
@mirka mirka deleted the fix/select-overflow branch August 17, 2022 14:13
@github-actions github-actions bot added this to the Gutenberg 14.0 milestone Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Components /packages/components [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CustomSelectControl: Long option strings aren't truncated

2 participants