Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Material UI Menu flickers whole page first time on click of button #18625

Closed
2 tasks done
rahul3103 opened this issue Nov 29, 2019 · 5 comments
Closed
2 tasks done

Material UI Menu flickers whole page first time on click of button #18625

rahul3103 opened this issue Nov 29, 2019 · 5 comments
Labels
support: Stack Overflow Please ask the community on Stack Overflow

Comments

@rahul3103
Copy link

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 馃槸

The first time the whole page flickers but after that it works like nothing happened before
https://youtu.be/sOTviY-dTWc

Expected Behavior 馃

It should not flicker and work how it was designed to

Steps to Reproduce 馃暪

Steps:

  1. I am using Menu and have changed the animation.
  2. Even the examples are flickering for the first time
import { useState } from 'react';
import Button from '@material-ui/core/Button';
import Menu from '@material-ui/core/Menu';
import styled, { keyframes } from 'styled-components';
import { KeyboardArrowDown } from '../../components/Icons';

const keyFrameOpen = keyframes`
  0% {
    height: 0px;
  }
  65% {
    height: 140px;
  }
  80% {
    height: 136px;
  }
  100% {
    height: 126px;
  }
`;

const keyFrameClose = keyframes`
  0% {
    opacity: 1 !important;
  }
  20% {
    height: 140px;
    opacity: 1 !important;
  }
  30% {
    height: 120px;
    opacity: 1 !important;
  }
  50% {
    opacity: 0 !important;
  }
  100% {
    height: 0px;
    opacity: 0 !important;
  }
`;

const DropDownButton = styled(Button)`
  &.MuiButtonBase-root {
    align-self: center;
    grid-column: 5/9;
    padding: 14px 20px;
    border-radius: 8px;
    border: 1px solid #f0f4f7;
    font-weight: 600;
    font-size: 14px;
    line-height: 150%;
    color: #3c4852;
  }
  &.MuiButton-root:hover {
    background-color: #fff;
    box-shadow: 0 8px 8px 0 #f0f4f7;
  }
  &.MuiButtonBase-root .MuiButton-label {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    font-size: 14px;
    line-height: 150%;
    color: #3c4852;

  }
`;

const StyledMenu = styled(Menu)`
  &.MuiPopover-root .MuiPaper-root {
    width: 176px;
    border: 1px solid #f0f4f7;
    border-radius: 8px;
    top: 72px !important;
    background-color: #fff;
    box-shadow: 0px 16px 32px #f0f4f7;
    transition: none !important;
    animation: ${({ open }) => (open ? keyFrameOpen : keyFrameClose)}
      ${({ open }) => (open ? '350ms' : '300ms')} ease-in-out 0s;
    transform: none !important;
    opacity: 1 !important;
  }
`;

const StyledArrowDown = styled(KeyboardArrowDown)`
  transition: transform 400ms ease-in-out;
  transform: ${({ open }) => (open ? 'rotate(180deg)' : 'rotate(0deg)')};
`;

const Dropdown = () => {
  const [anchorEl, setAnchorEl] = useState(null);

  const handleClick = event => {
    setAnchorEl(event.currentTarget);
  };

  const handleClose = () => {
    setAnchorEl(null);
  };
  return (
    <>
      <DropDownButton
        disableRipple
        variant="outlined"
        onClick={handleClick}
        endIcon={<StyledArrowDown open={anchorEl} size="16px" />}
      >
        Text
      </DropDownButton>
      <StyledMenu
        anchorEl={anchorEl}
        keepMounted
        open={Boolean(anchorEl)}
        onClose={handleClose}
        elevation={0}
        getContentAnchorEl={null}
        anchorOrigin={{
          vertical: 'bottom',
          horizontal: 'center'
        }}
        transformOrigin={{
          vertical: 'top',
          horizontal: 'center'
        }}
        variant="menu"
      >
        <p>text</p>
        <p>text</p>
        <p>text</p>
        <p>text</p>
        <p>text</p>
        <p>text</p>
      </StyledMenu>
    </>
  );
};

export default Dropdown;

Context 馃敠

Your Environment 馃寧

Tech Version
Material-UI v4.7.0
React v 16.12.0
Browser Chrome, Safari
Styled Components ^5.0.0-rc.2
Next js 9.1.4
@oliviertassinari oliviertassinari added the support: Stack Overflow Please ask the community on Stack Overflow label Nov 29, 2019
@support
Copy link

support bot commented Nov 29, 2019

馃憢 Thanks for using Material-UI!

We use GitHub issues exclusively as a bug and feature requests tracker, however,
this issue appears to be a support request.

For support, please check out https://material-ui.com/getting-started/support/. Thanks!

If you have a question on StackOverflow, you are welcome to link to it here, it might help others.
If your issue is subsequently confirmed as a bug, and the report follows the issue template, it can be reopened.

@support support bot closed this as completed Nov 29, 2019
@mrquincle
Copy link

Has this been solved?

@maulik9211
Copy link

I am experiencing the same issue.

@ReactWithRajesh
Copy link

still this issue persisting in select and menu dropdowns

@j-mendez
Copy link
Contributor

@RjSingh1529 check out #31849 for the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support: Stack Overflow Please ask the community on Stack Overflow
Projects
None yet
Development

No branches or pull requests

6 participants