Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

MDCRipple: long press and hiding element causes a crash #3527

Closed
robcaldecottvelo opened this issue Sep 6, 2018 · 2 comments
Closed

MDCRipple: long press and hiding element causes a crash #3527

robcaldecottvelo opened this issue Sep 6, 2018 · 2 comments

Comments

@robcaldecottvelo
Copy link

I am using the popular rmwc library which ships with MDC 0.39.1. If you have a ripple-enabled button/FAB and long-press it with the mouse (so you get a full ripple) and then immediately hide the element then mdc.ripple.js will crash when trying to remove a class from a root_ that has already been destroyed.

Here is a codesandbox:

https://codesandbox.io/s/3rpo0829q6

The code that shows the problem:

class App extends React.Component {
  state = { show: true };

  render() {
    return (
      <React.Fragment>
        <p>Long click on the button below (so you get a full ripple)</p>
        {this.state.show && (
          <Button
            raised
            onClick={() => {
              this.setState({ show: false });
            }}
          >
            Long click me
          </Button>
        )}
      </React.Fragment>
    );
  }
}

The crash occurs in this MDC code (mdc.ripple.js)

removeClass: function removeClass(className) {
  return instance.root_.classList.remove(className);
}
@kfranqueiro
Copy link
Contributor

This looks like #2460 except for deactivation rather than activation. I think this should be straightforward to fix.

@jamesmfriedman
Copy link
Contributor

@kfranqueiro updated sandbox for the issue.

I broke the other one because of my movement to separate packages.
https://codesandbox.io/s/qzwm42p1vw

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants