fix: don't reopen dropdownDiv if it was already open #6688
Merged
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.
The basics
npm run format
andnpm run lint
The details
Resolves
Fixes #6037
Proposed Changes
When fields that use the dropdownDiv are already open and then are clicked again, they will close (and not reopen)
Behavior Before Change
Behavior After Change
Reason for Changes
Feels more natural and expected, more similar to other UI inputs.
Test Coverage
Working on making unit tests, having trouble simulating a click on a field. Will add if we actually want to do this change.
Documentation
none
Additional Information
I had some free time and wanted to pick up a bug... Sadly this is complicated to do :/
The dropdown is automatically closed whenever a gesture is started (think mousedown). The field doesn't receive the click on itself until the gesture is confirmed to be a click on the field (think mouseup).
So, it's not that the menu "animates a reopen" - from the editor's perspective the menu was already closed and it is just always going to open. What needs to happen is the field needs to know "right before this gesture started, was the dropdown div already opened and owned by me? if so, don't open it again." It's not enough to just know the last owner of the dropdown div. You really need to know who owned it right before the current gesture closed it. Therefore,
gesture.ts
has to be involved here, and you can't just have the fields ask the dropdownDiv what to do.Note that with the current approach, this will affect all fields including custom fields that use the dropdown div. This seems fine based on the description of the current behavior as a "bug" but I wanted to note that. Because as an alternative, we could pass in
alreadyOpen
or whatever as a parameter toshowEditor
andshowEditor_
to let each field determine individually what to do. But that is more complicated and it's most likely that this is the desired behavior.Also note that for fields that use both widget div and dropdown div, this still works great. For example, the angle field uses both. When you click "the angle field" again you are actually clicking the html text input which eats the events, so the dropdown is never hidden in the first place, and simply remains open, as you would expect.
Alternatives Considered
gesture.handleUp
at the beginning, because that'd still be before the field gets it. or at the end, because that would hide it right after the field opens it for real.