Dropdown can not display selected element (string is fine)
See original GitHub issueWhat package(s) are you using?
-
carbon-components
- [ x]
carbon-components-react
Detailed description
I am using itemToElement to show my dropdown options, but now Dropdown can not show the selected element because the line " {selectedItem ? itemToString(selectedItem) : label}" should try to invoke “itemToElement” if it is available but now only string can be displayed .
<ListBox.Field
id={id}
tabIndex="0"
disabled={disabled}
aria-disabled={disabled}
aria-labelledby={`${labelId} ${fieldLabelId}`}
aria-describedby={helperId}
{...buttonProps}>
<span
id={fieldLabelId}
className={`${prefix}--list-box__label`}
title={selectedItem ? itemToString(selectedItem) : label}
{...getLabelProps()}>
{selectedItem ? itemToString(selectedItem) : label}
</span>
<ListBox.MenuIcon
isOpen={isOpen}
translateWithId={translateWithId}
/>
</ListBox.Field>
This is my expected result
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Angular 8 drop down selected option not showing, how come?
I would like to show "10" as the default selected value but whatever I do the drop down keeps showing a blank for...
Read more >Select Item activity not identifying the string from the dropdown ...
I'm able to identify the element and even in log I can see the correct result, it is just not selecting the option....
Read more >Label Control can't display the value selected in dropdown list
I try to display the selected value with dropdown list by using label control but cant display it in firefox but works fine...
Read more >ng-multiselect-dropdown - npm
Start using ng-multiselect-dropdown in your project by running ... selectAllText, String, Text to display as the label of select all option ...
Read more >How to get selected value in dropdown list using JavaScript
This property returns a string representing the value attribute of the <option> element in the list. If no option is selected then nothing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I guess not, 😄. I will let her know about this. Thanks!
I just wanted to chime in here and clarify that the design intent is not to have custom options like tags inside of the dropdown component. Similarly, custom items should not render in the field position. The rationale for this is that it can create some confusion UX-wise around how to use the control (for example if it looks like a multi-select but doesn’t behave like one)
Feel free to reach out on #carbon-design-system on Slack if there are any concerns with this!
For folks on the team, can see our recent thread on the support channel for the resolution 👍