Prevent share dropdown to close too early with autocomplete

When clicking on an autocomplete result in the sharing dropdown,
it will mistakenly be detected as being clicked outside and would
trigger the sharing dropdown closing.

This fix adds a check to detect clicks inside the autocomplete and
prevent closing the dropdown in that case.

This fixes #4142