mui / mui-x

MUI X: Build complex and data-rich applications using a growing list of advanced React components, like the Data Grid, Date and Time Pickers, Charts, and more!
https://mui.com/x/
4.57k stars 1.35k forks source link

[TimePicker] Ref is accessed just after being removed #7493

Closed antoinerousseau closed 8 years ago

antoinerousseau commented 8 years ago

Problem Description

This bug is hard to reproduce and only happens sometimes: when selecting a time, I get this:

TypeError: Cannot read property 'getSelectedTime' of undefined

File "webpack:///./~/material-ui/TimePicker/TimePickerDialog.js" line 68 col 1 in r.handleTouchTapOK _this.props.onAccept(_this.refs.clock.getSelectedTime());

File "webpack:///./~/material-ui/TimePicker/Clock.js" line 111 col 1 in [anonymous] onChangeMinutes(time);

I believe it could be because the Clock is sometimes unmounted just before it is accessed through its ref: https://github.com/callemall/material-ui/blob/a76c0889055fbc7cc854b391f915cd477f3687a8/src/TimePicker/TimePickerDialog.js#L60

Maybe calling this.dismiss(); at the end of the function would help?

Versions

tintin1343 commented 8 years ago

@antoinerousseau : I know you mentioned this:

This bug is hard to reproduce and only happens sometimes

I tried a lot to reproduce this, but I was not able to generate this behavior. Are you trying to emulate a mobile browser on chrome?

antoinerousseau commented 8 years ago

It happened in a real Android phone (Moto G). I'll let you know if it happens again.

tintin1343 commented 8 years ago

@antoinerousseau : Appreciate your input here. Thanks!

antoinerousseau commented 8 years ago

@tintin1343 I'm using Rollbar.com to report JS errors

tintin1343 commented 8 years ago

I am closing this issue for now as its not reproducible. If you find anything further do leave a comment below and I wlll reopen it. Thanks!