react-autosuggest icon indicating copy to clipboard operation
react-autosuggest copied to clipboard

stopPropagation() causes autosuggest doesn't close the dropdown

Open ghost opened this issue 6 years ago • 4 comments

I have a button inside the suggestion as follows: alt text

When I click on the right side button (close icon) I have to use e.stopPropagation() to prevent clicking on the suggestion itself and then remove that suggestion. After removing the item I can't close the dropdown anymore when click outside of the dropdown.

ghost avatar Jul 30 '19 15:07 ghost

I have exactly the same issue. Any ideas on how to fix it?

ronaklalwaniii avatar Aug 05 '19 05:08 ronaklalwaniii

I managed it like this: I removed e. stopPropagation() so now when we click on the close button two different functions are being called in this order: 1- onRemoveClick 2- onSuggestionSelected. When I click on remove button I set a flag true and then inside onSuggestionSelected I'm checking that flag and if that is not true I will go through the functionality, otherwise it does nothing.

ghost avatar Aug 05 '19 09:08 ghost

@sepehra1313 Can you explain what do you mean by: otherwise it does nothing.. How do you prevent the dropdown from closing without e.stopPropagation()?

gilad-solter avatar Aug 06 '19 13:08 gilad-solter

I managed it like this: I removed e. stopPropagation() so now when we click on the close button two different functions are being called in this order: 1- onRemoveClick 2- onSuggestionSelected. When I click on remove button I set a flag true and then inside onSuggestionSelected I'm checking that flag and if that is not true I will go through the functionality, otherwise it does nothing.

Still now working as expected since onRemoveClick would still close the suggestion list immediately after fired, I would like to keep the suggestion list open while interacting with its childs.

Zacele avatar Jun 17 '24 03:06 Zacele