question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dropdown can not display selected element (string is fine)

See original GitHub issue

What 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
image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ilovepumpkincommented, Mar 30, 2020

I guess not, 😄. I will let her know about this. Thanks!

0reactions
joshblackcommented, Mar 31, 2020

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 👍

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found