bug(Shape): Fix some properties not persisting correctly when modified #1487
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.
This fixes #1484
PA tracks internally which shapes are currently selected and the most prominent location of changes of this selection occur when you use the select tool to click on other shapes or deselect the active shape.
Before this PR, the select tool would immediately update the selection state when the
mouseDown
event is fired. This PR changes this behaviour to wait untilmouseMove
ormouseUp
.When you're editing for example the name of a shape and you directly click on another shape or even just the map (causing a deselect), a bunch of browser events are fired. First the
mouseDown
event fires, which until now changed the selection info immediately, then thechange
event fires, which indicates that the name input field changed content and finallymouseUp
is fired.As you can see by the time the change event hits, we've already changed our selection to either a different shape or cleared the selection info. Which in turn means that the updateName function either changes the name of the wrong shape or simply doesn't have any shape to update.
By delaying the selection change to
mouseMove
ormouseUp
, we're ensuring that these events still operate on the originally selected shape.Some of you might wonder why the other input field (i.e. 'value') mentioned in the related ticket was working correctly before these changes. That's because that field is still using a legacy way to detect which shape is active that reactively watches the main selection system. This legacy system was getting its update a tick later which happens to be after the
change
event fired.