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

[Autocomplete/TextField] dropdown closes on mouseup over textfields #37046

Closed
2 tasks done
nathanielohler-wf opened this issue Apr 26, 2023 · 4 comments
Closed
2 tasks done
Labels
component: autocomplete This is the name of the generic UI component, not the React module! discussion

Comments

@nathanielohler-wf
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Link to live example:
https://codesandbox.io/s/infallible-mccarthy-bg665h?file=/demo.tsx
Steps:

  1. Mousedown on whitespace in autocomplete (avoid whitespace within bounds of the clear option): dropdown should appear
  2. Slide cursor over a textfield
  3. Mouseup: dropdown disappears

Current behavior 😯

On mouseup, the dropdown closes instead of remaining open.

Expected behavior 🤔

The dropdown should remain open.

Context 🔦

In our system, on mousedown the pills change size and become larger (the pill delete icon is only shown when entering the autocomplete). The pills slide underneath the mouse frequently, making the dropdowns flash open/closed instead of remaining open.

Initially thought it may be related to: #36892, but problem occurs in the enabled state.

Your environment 🌎

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
@nathanielohler-wf nathanielohler-wf added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 26, 2023
@sai6855
Copy link
Contributor

sai6855 commented Apr 27, 2023

@nathanielohler-wf I'm not able to reproduce the issue, can you add screen recording?

Btw, #36892 is not released yet so probably it's not causing the issue

@zannager zannager added the component: autocomplete This is the name of the generic UI component, not the React module! label Apr 27, 2023
@nathanielohler-wf
Copy link
Author

Screen.Recording.2023-04-28.at.3.56.52.PM.mov

It's not obvious, but the mouse down occurs in the blank space, slide the mouse over the pill, then mouseup.

@michaldudak
Copy link
Member

michaldudak commented May 17, 2023

Your use case is pretty unusual, so I'm not keen on changing the logic for everyone. You may work around this issue by using pointer capture in the text field's onPointerDown:

<Autocomplete
  multiple
  id="tags-standard"
  options={top100Films}
  getOptionLabel={(option) => option.title}
  defaultValue={[top100Films[13]]}
  renderInput={(params) => (
    <TextField
      {...params}
      variant="standard"
      label="Multiple values"
      placeholder="Favorites"
      onPointerDown={(event) => event.currentTarget.setPointerCapture(event.pointerId)}
    />
  )}
/>

Let me know if it helps.

@michaldudak michaldudak added discussion and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 17, 2023
@michaldudak michaldudak removed their assignment May 17, 2023
@michaldudak
Copy link
Member

I'm assuming it works.

@michaldudak michaldudak closed this as not planned Won't fix, can't repro, duplicate, stale Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: autocomplete This is the name of the generic UI component, not the React module! discussion
Projects
None yet
Development

No branches or pull requests

4 participants