Hey, what do you think of adding type definition support in this select dropdown? #29034
FrancoAguzzi
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is your feature request related to a problem? Please describe.
Being a problem or not depends on the eyes of the seer.
The support I'd love to see is this Select Dropdown being a way of people defining default typed object properties values.
Describe the solution you'd like
How?
Nowadays, defining typed objects is a challenge for me.
I am not the only one? IDK -- maybe I didn't find the way to do so?
The desire: typed objects setting via Storybook UI.
The gap: object controls in Storybook UI are ruleless as per my raw Storybook knowledges.
The solution I found: setting
options
andmapping
objects for these options that are for sure objects of the property type.The problem with the solution: I cannot initialize my
.stories
UI documentation with some value included in theoptions
array, resulting in "Choose option..." label display in Select dropdown default option.How I wished to fix this?: by using
render
function, I tried to mutate price to be the first value ofoptions
with the below code snippet:Why my approach did not work?: because
SingleSelect
Storybook component definesselectedKey
only at render execution. Onvalue
update,SingleSelect
does not updateselectedKey
becauseselectedKey
is a defined asconst
.How could this be different?: if
selectedKey
was a state (useState
) and Storybook had anuseEffect
with the dependency array as[value]
, whenevervalue
is modified,selectedKey
would be modified as well.Describe alternatives you've considered
OK, no more over-ideating now, what do you think about supporting creators to manage
SingleSelect
controls, programatically?I appreciate your attention,
Wish you have a great time 🍞🙏🏼
Are you able to assist to bring the feature to reality?
yes, I can
Additional context
I'd be comfortably realized to open a PR with this proposed enhancement for your lib 🙂
Beta Was this translation helpful? Give feedback.
All reactions