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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgradeElement does not apply ripple effect for element created after window.onload #804

Closed
alextekartik opened this issue Jul 7, 2015 · 6 comments

Comments

@alextekartik
Copy link

I took the exact same sample from the getting started page. In the following sample, the ripple effect is applied when pressing the button

http://codepen.io/alextekartik/pen/oXqqEm

However, if I call the same code after window.onload, the ripple effect is not applied properly

http://codepen.io/alextekartik/pen/vORRdq

A sample that create 3 buttons the same way (one directly, one during onload and one after some delay) shows the same issue (only the first has the ripple effect:

http://codepen.io/alextekartik/pen/vORRvY

Is there any other initialization code needed or is this a bug?
(tested on chrome and firefox)

@Garbee
Copy link
Collaborator

Garbee commented Jul 7, 2015

@passy wow, looks like Issue #206 just got revived from the grave.

@Garbee
Copy link
Collaborator

Garbee commented Jul 7, 2015

Just assigning a plain bug label until some more effort can be put into this. I'm not sure where the problem is spawning from exactly, looks related to how the Component Handler is dealing with things, but also could be one or the other components directly have a bug in this instance.

@Garbee
Copy link
Collaborator

Garbee commented Jul 7, 2015

Reviewing the old issue, looks like the ripple component is the core cause. Need to handle failure better.

@xdissent
Copy link
Contributor

xdissent commented Jul 8, 2015

I don't think it's ripple's fault, it's just that componentHandler.upgradeElement() doesn't work like you might expect. It only applies a single component to an element, ignoring the element's class names altogether. So if you want to dynamically create a button with ripple, you have to componentHandler.upgradeElement(el, 'MaterialButton') then componentHandler.upgradeElement(el, 'MaterialRipple'). The individual components do sometimes look at class names though, so you can get a weird state where the ripple is set up by a component (as seen in MaterialButton) but the ripple component is never applied.

So, since components do look at class names to determine their behaviour, I think componentHandler.upgradeElement() should simply take an element and determine the appropriate components to apply based on class names alone. I've pushed a (backwards compatible) fix here: #890

@waltercolindres
Copy link

+1

@sgomes
Copy link
Contributor

sgomes commented Oct 2, 2015

I believe this was fixed with #1498, please reopen if not.

@sgomes sgomes closed this as completed Oct 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants