BUGFIX: Stop click event propagation on selected element in select box header #3341
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes: #3057
The Problem
Hard to pin down, but I'll try: The issue described in #3057 relates to the
AssetEditor
which uses the<SelectBox/>
component for input. The<SelectBox/>
component uses the<DropDown/>
component for rendering. The<DropDown/>
component understands a click on its header as a request to toggle itsexpanded
state. Whenexpanded === true
, the<SelectBox/>
changes its header into a search input, so the user can search through the available select options.Now, the
AssetEditor
kind of misuses the<SelectBox/>
for its purpose. It narrows the available select options to the currently selected asset, so the<SelectBox/>
displays the latter properly. This however means that the behavior described above leads to a search input, but only one available select option: the currently selected one. (Side note: On input, the search is still being performed, the<SelectBox/>
simply does not show the resulting options)The Solution
I've tried to correct the behavior of the
AssetEditor
, so that it shows the search results, but with no luck.So, I ended up implementing the suggestion from #3057. Through
stopPropagation
, a click on the currently selected option won't toggle the underlying<DropDown/>
component any longer.