You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When used this way, however, there doesn't seem to be a way to control what is displayed as the text when the menu is closed.
Binding something to value would have controlled this at one point, but the bug fix in #801 changed the code so that it will always find the selected item and use the textContent of the node for the selected text. Given the example above, Cookies Example 1 would end up being displayed in the UI.
The desired use case would be to have a more complex menu item structure for display but to still use a simple string representation for the collapsed state.
There are two possibilities I've considered for fixing this:
Adding an optional display text field to the options
Updating the FormattedOption definition for selects include a selectedDisplayText field
In the foundation code, if the selected option has selectedDisplayText set use it instead of the textContent
Adding an optional function to set the selected text
Updating the SelectProps to include a function that accepts a FormattedOption and returns a string
In the foundation code, if the component has a text selection function use it to determine the text to display instead of textContent
Before making a change and submitting a PR:
Is this functionality already possible without a change?
If not, which of the two approaches best matches usage patterns of the library?
The text was updated successfully, but these errors were encountered:
@ajalexander Sorry for not getting back to you sooner. We've been occupied with the release of version 14. While we hope to address your issue soon, there are still a few bugs on our priority list that need attention. Feel free to submit a pull request – contributions are always welcome!
RMWC Version 8.0.3
The
enhanced
version of the<Select>
component allows for labels to be JSX elements in addition to strings. For example, the code below:When used this way, however, there doesn't seem to be a way to control what is displayed as the text when the menu is closed.
Binding something to
value
would have controlled this at one point, but the bug fix in #801 changed the code so that it will always find the selected item and use thetextContent
of the node for the selected text. Given the example above,Cookies Example 1
would end up being displayed in the UI.The desired use case would be to have a more complex menu item structure for display but to still use a simple string representation for the collapsed state.
There are two possibilities I've considered for fixing this:
FormattedOption
definition for selects include aselectedDisplayText
fieldselectedDisplayText
set use it instead of thetextContent
SelectProps
to include a function that accepts aFormattedOption
and returns astring
textContent
Before making a change and submitting a PR:
The text was updated successfully, but these errors were encountered: