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

Elements behind detached overlay cancel button get clicked as well #853

Closed
ArcoMul opened this issue Jan 3, 2022 · 5 comments · Fixed by #922
Closed

Elements behind detached overlay cancel button get clicked as well #853

ArcoMul opened this issue Jan 3, 2022 · 5 comments · Fixed by #922

Comments

@ArcoMul
Copy link

ArcoMul commented Jan 3, 2022

Description

I'm noticing that when the cancel button of detached overlay is clicked, that elements behind the overlay are also being clicked.

Reproduction

Here is a sandbox showing the problem: https://eqkl7.csb.app/

Steps

  1. Open the sandbox in a new window
  2. Open the browser devtools to emulate mobile touches (only Firefox seems to emulate touches the right way)
  3. Click the input field to open the detached overlay view
  4. Click the cancel button in such a way that you also click on the 'Search' button behind
  5. Notice that after clicking the cancel button it says 'Search button got clicked' in the console

Expected behavior

I expect the detached overlay to close when clicking 'cancel' but not to be any other element behind it being clicked.

Environment

  • OS: Windows
  • Browser: Desktop Firefox (using devtools), Mobile Firefox, Mobile Chrome (note: not able to reproduce using desktop Chrome devtools)
  • Autocomplete version: 1.5.1
@ArcoMul
Copy link
Author

ArcoMul commented Jan 3, 2022

Some interesting finds:

@sarahdayan
Copy link
Member

sarahdayan commented Jan 13, 2022

I'm reproducing the issue on Firefox with touch gestures enabled (event occurs with a slight delay). The behavior not happening on debug mode is likely caused by the blur state action having a special case for it (related issue).

I will investigate.

@francoischalifour
Copy link
Member

That's indeed because the input loses focus. We could either prevent touch events on the panel elements, or not attach this blur logic on the input in Detached mode.

@prestarocket
Copy link

Does anyone have a solution for this bug?

@francoischalifour
Copy link
Member

Another thing to try is to preventDefault and stopPropagation on the cancel button click:

onClick() {
autocomplete.setIsOpen(false);
setIsModalOpen(false);
},

Would you like to PR @prestarocket?

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

Successfully merging a pull request may close this issue.

4 participants