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.

Labels in control are hidden when Select used within an expander (collapsed) with a defaultValue.

See original GitHub issue

Description

  1. 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).
  2. After toggling expander to open (see below), the value is in the control but is not shown because the CSS property ‘width’ is 0px.
  3. 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 image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:6

github_iconTop GitHub Comments

1reaction
geochantocommented, Dec 8, 2019

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.

0reactions
ebonowcommented, Dec 20, 2020

@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

Read more comments on GitHub >

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

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