Labels in control are hidden when Select used within an expander (collapsed) with a defaultValue.
See original GitHub issueDescription
- If Select component is wrapped in an expander (or collapse-like component), and a default value is set, and the expander is closed upon initial creation, then the value is not shown in the control because of the WrappedComponent has inserted a
<div>
with a width of 0 (width: 0px). - After toggling expander to open (see below), the value is in the control but is not shown because the CSS property ‘width’ is 0px.
- It not possible to recover from this state by attempting to reselect items, or by clearing items in control.
Expected Behavior
There should a label in the control, but instead it is effectively hidden by a width: 0px from a wrapping <div>
.
There is a similar issue: ‘Default selected items don’t appear when using transitions if select is hidden #3029’. The discussion in #3029 seems to indicate that the issue has to do with the Collapse component, which stores a ‘width’ in its state (initially set to ‘auto’), but appears it does not get re-computed.
Sandbox https://codesandbox.io/s/jz4112nvyw
Screenshot
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:6
Top Results From Across the Web
aria-expanded - Accessibility - MDN Web Docs - Mozilla
Use the aria-owns property on the elements that own expandable ... By default, some roles are hidden or collapsed and other roles are...
Read more >Xamarin Community Toolkit Expander - Microsoft Learn
In this example, the Expander is collapsed by default and displays a Label as its header. Tapping on the header results in the...
Read more >WPF Expander inside ListBox ItemTemplate IsExpanded ...
If I'm understanding your code, right now you have the SelectedItem of the ListBox expanded and the other items collapsed. If the selected...
Read more >Combobox | APG | WAI - W3C
The popup is hidden by default, i.e., the default state is collapsed. The conditions that trigger expansion -- display of the popup --are...
Read more >Element: <oj-select-single> - Oracle
The JET form component properties that are used for user ... <oj-select-single class="oj-form-control-max-width-md"> ... Default Value:.
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 Free
Top 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
Running into the same issue. Tried the top answer here, didn’t work: https://github.com/facebook/react/issues/4101
I’m trying to use value instead of defaultValue, but that doesn’t seem to be working either.
If I start with the open state for <Collapse/>, defaultValue populates. But if it starts collapsed, defaultValue doesn’t populate when the state is toggled on, even though I can see the defaultValue prop is passed down to react-select.
UPDATE: Seems I found the culprit for my case. the defaultValue was actually there, but it was hidden by label having zero width via inline CSS. It seems that this was caused by using the makeAnimated component. After removing it, CSS width is back to normal and default label shows up.
@alturium @muserrefakillibaykus
I have not been able to reproduce this even in the sandbox link provided. I am uncertain what if anything has changed, but if someone can replicate this issue please provide some more information so we can reproduce the described error, reopen this issue and further troubleshoot.
In the meanwhile given that I am unable to replicate it, I will close it for time being.![Screen Shot 2020-12-19 at 9 38 23 PM](https://user-images.githubusercontent.com/1007579/102704607-3b4bd680-4243-11eb-8e4d-39defa665bbb.png)