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.

Support css transitions for menu open/close

See original GitHub issue

I’m very new to react and react-select, but it seems to me that the strategy of removing the .Select-outer-menu node instead of just styling it as invisible (or doing a getComputedStyle() trick plus styling for dom performance) interferes with css transitions for animating the opening and closing of the menu items.

Can it please somehow support animated transitions when opening and closing the menu?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:10
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
sag1vcommented, Aug 27, 2018

@ptimson No, not something that fully works (without changing the source code of course). I’m not sure but maybe the new version Select 2.0 is supporting transition or animation out of the box. Maybe @JedWatson can shed some light on this.

2reactions
wongsyneecommented, May 15, 2019

So what I did to have the animation on the menu is to customise the Menu component entirely. Below is my working code, (I am using CSS modules here):

// JS file
// Need to import components from React-Select.
import Select, { components } from 'react-select'

const Menu = props => {
  return (
    <Fragment>
      <components.Menu {...props} className={styles.menu}>
        {props.children}
      </components.Menu>
    </Fragment>
  )
}

export default () => (
  <Select
    id={genID}
    options={listItems}
    className={styles.select}
    classNamePrefix="select"
    defaultMenuIsOpen={false}
    placeholder={placeholder}
    onChange={this.handleOnChange}
    blurInputOnSelect={false}
    tabSelectsValue={false}
    menuShouldScrollIntoView={true}
    components={{ Menu }}
  />
)
// CSS Modules
.menu {
    animation: fade--in .2s ease-in-out;
}

@keyframes fade--in {

    0% {
        opacity: 0;
        transform: translateY(5rem);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

Hope that helps anyone who has stumbled across this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transition on menu open/close - css - Stack Overflow
I try to add a CSS transition when menu is opening/closing but it seems not to work. This is the div that should...
Read more >
Menu Open/Close Animation - CodePen
URL Extension Required. When linking another Pen as a resource, make sure you use a URL Extension of the type of code you...
Read more >
Using CSS transitions - CSS: Cascading Style Sheets | MDN
Using transitions when highlighting menus. A common use of CSS is to highlight items in a menu as the user hovers the mouse...
Read more >
Using CSS Transitions on Auto Dimensions
We've all been there. You've got an element you want to be able to collapse and expand smoothly using CSS transitions, but its...
Read more >
Cool CSS Hamburger Menu Icons and Their Animations
They offer unique hamburger menus that are sure to amuse visitors. Hamburger menu animation with velocity.js. HTML; Less; JS. Result; Skip ...
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