Default selected items don't appear when using transitions if select is hidden
See original GitHub issueSteps to reproduce:
- Create a component that initially hides its children using
display: hidden
- Put a React Select in this component, and make it a multi-select
- Enable animations
- Add some default selected items
Expected behaviour
The default selected items should appear inside the select box
Actual behaviour
The default selected items do not appear. In particular, they have a width of 0:
This is because the React transition has not correctly expanded their widths to their ordinary widths.
This behaviour is replicated in this sandbox. Click the button to expand the Expander.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Manage objects with the Selection pane - Microsoft Support
Use the Selection pane to move objects backwards and forwards, hide or show objects, and to group or ungroup objects.
Read more >How to hide a <option> in a <select> menu with CSS?
5. Instead of hiding and showing on a search. Try and populate the select depending on the search · 1. I agree with...
Read more >visibility - CSS: Cascading Style Sheets - MDN Web Docs
The visibility CSS property shows or hides an element without changing the layout of a document. The property can also hide rows or...
Read more >Select layers and objects – Figma Help Center
If you hide a layer we won't show in the Select layer menu. You will need to toggle ... The default behavior for...
Read more >.hide() | jQuery API Documentation
When a custom queue name is used the animation does not automatically start; ... If an element has a display value of inline...
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
If anyone needs a solution, this worked for our project. Basically, when Exit is called for a MultiValue, width is set directly on the ref div. The next state change sets the width to 0 and the CSS width transition does its magic. A small side benefit is that there is no measuring required at mount.
// Collapse.tsx
// AnimatedMultiValue.tsx
That does seem to work on the sandbox! I’ll have a look at whether that refactor will work with our code and get back 😃
EDIT: I’ve checked with our code, and
visibility: hidden
isn’t ideal, because it leaves that huge space around the element. Any ideas?