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

[Slider] Remove touchend event listener #12923

Conversation

brian-growratio
Copy link
Contributor

I added the touchend event listener to fix #12922

@oliviertassinari oliviertassinari changed the title added removeEventListener for touchend to Slider [Slider] Remove touchend event listener Sep 18, 2018
@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work component: slider This is the name of the generic UI component, not the React module! labels Sep 18, 2018
@oliviertassinari oliviertassinari merged commit a59903a into mui:master Sep 18, 2018
@oliviertassinari
Copy link
Member

@brian-growratio It's a great first pull request on Material-UI 👌🏻. Thank you for working on it!

@brian-growratio
Copy link
Contributor Author

Any time, thanks for the hard work guys!

@brian-growratio
Copy link
Contributor Author

@oliviertassinari Sorry to bother you on this one line fix, but this is actually a pretty breaking problem in my app, and the last version without it was 1.0.0-alpha.12 which is missing quite a few fixes.

I was wondering if you know when the fix will be pushed to the npm repo.

Again, thank you for all the hard work on this library, this open source community has easily made a better component library than anything I've seen before.

@brian-growratio brian-growratio deleted the 12922-slider_touchend_event_listener_never_removed branch September 19, 2018 13:43
@oliviertassinari
Copy link
Member

@brian-growratio The fix will be released this weekend.

@brian-growratio
Copy link
Contributor Author

Thank you so much!

In the rare case that someone needs this right now and can't wait for the fix to be applied, here's a temporary fix you can use in your code (for React v16 and greater) that uses a slider:

class YourComponent extends React.Component {
    constructor(props){
        super(props);
        this.sliderRef = React.createRef();
    }

    handleDragEnd = (event) => {
        document.body.removeEventListener('touchend', this.sliderRef.current.handleMouseUp);
        ...<rest of your drag end event code>
    }

    render() {
        return (
            <Slider <your props> innerRef={this.sliderRef} />
        );
    }
}

marcelpanse pushed a commit to marcelpanse/material-ui that referenced this pull request Oct 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: slider This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants