material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[AutoComplete] Doesn't selects option on click

Open w01fgang opened this issue 10 years ago • 9 comments

Problem Description

Click with mouse doesn't select option in dropdown menu, the menu closes before filling the field. I use touchpad on Mackbook, so the tap works well, but the click doesn't. On documentation site, in v0.15.0-alpha.1, the problem exists.

Possible solution

In auto-complete.js I was found the problem in handleBlur function:

this.timerBlurCloseId = setTimeout(() => {
        this.close();
      }, 0);  // when I change from 0 to 300, click works well

Versions

  • Material-UI: v0.15.0-alpha.1
  • React: 0.14.7
  • Browser: Chrome 48.0.2564.116 (64-bit), Safari 9.0.3

w01fgang avatar Mar 02 '16 21:03 w01fgang

Experiencing the same issue, any progress on this?

rynti avatar Mar 07 '16 17:03 rynti

Same behavior for me in 0.15.0-alpha.1.

danpozmanter avatar Mar 08 '16 04:03 danpozmanter

@w01fgang thanks for opening this issue. Yes we do have this problem in documentation site. I checked your solution and it seems to working correctly. what do you think @mbrookes @newoga?

heetvachhani avatar Mar 10 '16 20:03 heetvachhani

Invoking @callemall/material-ui, as this is the third or fourth issue lately requiring timers in strange places to solve race events, and it feels like we need a consistent solution.

Ideas anyone?

mbrookes avatar Mar 10 '16 20:03 mbrookes

@w01fgang I'm not sure to understand. I don't see any difference when using 300 instead of 0. @heetvachhani Do you have a gif?

oliviertassinari avatar Mar 11 '16 20:03 oliviertassinari

@oliviertassinari Yes, Here's gif.

fgp4yqe1nw

screen shot 2016-03-11 at 2 56 21 pm

heetvachhani avatar Mar 11 '16 21:03 heetvachhani

Oh, I get it! I was using my mac touch pad. That explain why I haven't noticed it. @heetvachhani Thanks.

oliviertassinari avatar Mar 11 '16 21:03 oliviertassinari

Yes, it's work if you use Macbook with touchpad, tap works well. But there is a comment: The blur event occurs first on a click device and after on a touch device The popup menu closes before click on them.

setTimeout(() => {
        this.close();
      }, 0);

So, there is no sense to use setTimeout with zero, because the function passed to setTimeout start immediately.

w01fgang avatar Mar 11 '16 21:03 w01fgang

That should be fixed by https://github.com/callemall/material-ui/pull/3669.

oliviertassinari avatar Mar 12 '16 11:03 oliviertassinari