Ripple is broken on elements with `display: none` on page load
See original GitHub issueWhat MDC-Web Version are you using?
0.12.1
What browser(s) is this bug affecting?
Google Chrome Version 57.0.2987.133 (64-bit) Mozilla Firefox Version 52.0.2 (64-bit) Others not tested.
What OS are you using?
Arch Linux Kernel 4.10.8-1
What are the steps to reproduce the bug?
- Open this codepen: https://codepen.io/draoncc/pen/OgLrjN
- Observe the behaviour of ripples on the buttons.
Note: Alternatively to setting the display state to ‘none’ by script the behaviour can be reproduced by setting an inline style of display: none
on the ripple element to break.
What is the expected behavior?
Both buttons have working ripples regardless of “initial” display state.
What is the actual behavior?
The ripple on the #broken-button
, which’s style is set to display: none
on run of the script, does not work properly.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
jquery - Ripples Effect not Showing, How Can I Fix?
It looks like the two scripts (the one for JQuery and the one for Ripples) are not present on the home page of...
Read more >ion-ripple-effect - Ionic Framework
The ripple effect component adds the Material Design ink ripple interaction effect. This component can only be used inside of an <ion-app> and...
Read more >Visibility hidden vs display none – What is the difference in CSS
When visibility:hidden is applied to an HTML element, it is not visible in the page, which makes sense. But the critical thing to...
Read more >Populating the page: how browsers work - Web Performance
Web performance is what we have to do to make the page load happen as quickly as ... and its children and any...
Read more >Ripples | Angular Material
By default, a ripple is activated when the host element of the matRipple directive receives mouse or touch events. Upon being pressed, a...
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
It works either way.
In your case, call
document.querySelector('#button').MDCRipple.layout()
after changingdisplay
property of the button.As @anton-kachurin mentioned,
layout
is now also exposed at the component level on mdc-ripple, which makes this issue resolvable by callinglayout
on ripples when your element is no longerdisplay: none
. As such, I’m going to close this issue.If anyone still encounters problems particular to a specific use case, please enter a new issue if you think there is something that material-components-web needs to do to resolve it. Thanks!