Skip to content

Conversation

aymeric-giraudet
Copy link
Member

@aymeric-giraudet aymeric-giraudet commented Nov 16, 2022

Our current custom renderer implementation with React does not close the panel when clicking outside of it, even when debug is false.

The deps list in the useEffect should not have refs as they are stable, which also means previously the effect only ran once so the event listeners did not get added, which is why I added autocompleteState.isOpen as it will create a new ref for panel each time it's opened.
I also added a missing mousedown event so it works on desktop too.

Also removed the debug option as it prevents from closing when clicking outside, I don't think it should be kept as users base their implementations on our examples and it's not obvious that debug does this.

@aymeric-giraudet aymeric-giraudet requested review from a team, dhayab and sarahdayan and removed request for a team November 16, 2022 11:07
@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 27010dc:

Sandbox Source
@algolia/autocomplete-example-github-repositories-custom-plugin Configuration
@algolia/autocomplete-example-instantsearch Configuration
@algolia/autocomplete-example-playground Configuration
@algolia/autocomplete-example-preview-panel-in-modal Configuration
@algolia/autocomplete-example-react-renderer Configuration
@algolia/autocomplete-example-starter-algolia Configuration
@algolia/autocomplete-example-starter Configuration
@algolia/autocomplete-example-reshape Configuration
@algolia/autocomplete-example-vue Configuration

Copy link
Member

@sarahdayan sarahdayan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great fix!

Let's update the documentation as well so it's consistent with this example.

@aymeric-giraudet aymeric-giraudet merged commit b133e85 into next Nov 16, 2022
@aymeric-giraudet aymeric-giraudet deleted the fix/close-on-mousedown branch November 16, 2022 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants