Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Select" control does not support string with extra spaces as an option #17051

Closed
daniel-stoian-lgp opened this issue Dec 21, 2021 · 3 comments · Fixed by #22334
Closed

"Select" control does not support string with extra spaces as an option #17051

daniel-stoian-lgp opened this issue Dec 21, 2021 · 3 comments · Fixed by #22334

Comments

@daniel-stoian-lgp
Copy link

daniel-stoian-lgp commented Dec 21, 2021

Describe the bug
Recently, we migrated from knobs to controls using storybook 6.3.12 and we have usecases where a component must be tested with strings with extra spaces
When selecting a string with extra spaces( example "Hello there" with extra spaces between the 2 words) in a select control, the selected value is rendered as undefined and the text is not displayed in our components.

When we used knobs, the generated HTML select had each option with a value attribute. and there was no issue in using strings with extra spaces

image

With controls, the options don't have a value attribute.

image

When trying to select an option, the string with extra spaces appears with only 1 space
image

After selecting it, the dropdown looks as if no option is selected and the url is appended with this string: &value:!undefined

image

To Reproduce
In any select control, put a string with extra spaces or a string which starts with a space as an option and select it

@daniel-stoian-lgp daniel-stoian-lgp changed the title Select control does not support string with extra spaces for an option "Select" control does not support string with extra spaces as an option Dec 21, 2021
@megbailey
Copy link

I have experienced this same issue when converting knobs to controls. Adding the additional space allowed us to bypass the sorting of numbered options as numbers allowing the options to show in the correct order when the label differed from the number value. Now, if the option has a different label, it is placed last in the list rather than in string order.
Screen Shot 2023-04-13 at 12 56 02 PM

@oxcened
Copy link
Contributor

oxcened commented May 2, 2023

I've submitted a pull request that fixes this 🎉

@anniepauline
Copy link

is it up for grabs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants