Canvas: Stop selecto box from triggering when programmatically selecting elements (#51579)

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
Nathan Marrs 2022-06-29 10:19:48 -07:00 committed by GitHub
parent 5d9ffe54ee
commit 66c911f263
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

View File

@ -4581,7 +4581,7 @@ exports[`better eslint`] = {
"public/app/features/canvas/runtime/root.tsx:2845174121": [
[24, 19, 36, "Do not use any type assertions.", "1413431594"]
],
"public/app/features/canvas/runtime/scene.tsx:2490140997": [
"public/app/features/canvas/runtime/scene.tsx:4285479205": [
[155, 61, 25, "Do not use any type assertions.", "588553285"],
[160, 42, 25, "Do not use any type assertions.", "588553285"]
],
@ -10980,10 +10980,9 @@ exports[`better eslint`] = {
[41, 64, 3, "Unexpected any. Specify a different type.", "193409811"],
[41, 69, 3, "Unexpected any. Specify a different type.", "193409811"]
],
"public/app/plugins/panel/canvas/editor/LayerElementListEditor.tsx:2866351070": [
"public/app/plugins/panel/canvas/editor/LayerElementListEditor.tsx:374041207": [
[21, 33, 3, "Unexpected any. Specify a different type.", "193409811"],
[40, 30, 44, "Do not use any type assertions.", "712744497"],
[50, 20, 3, "Unexpected any. Specify a different type.", "193409811"]
[40, 30, 44, "Do not use any type assertions.", "712744497"]
],
"public/app/plugins/panel/canvas/editor/PlacementEditor.tsx:1494111960": [
[33, 53, 3, "Unexpected any. Specify a different type.", "193409811"]

View File

@ -394,8 +394,12 @@ export class Scene {
this.moveable!.isMoveableElement(selectedTarget) ||
targets.some((target) => target === selectedTarget || target.contains(selectedTarget));
if (isTargetMoveableElement) {
// Prevent drawing selection box when selected target is a moveable element
const isTargetAlreadySelected = this.selecto
?.getSelectedTargets()
.includes(selectedTarget.parentElement.parentElement);
if (isTargetMoveableElement || isTargetAlreadySelected) {
// Prevent drawing selection box when selected target is a moveable element or already selected
event.stop();
}
}).on('selectEnd', (event) => {

View File

@ -48,7 +48,7 @@ export class LayerElementListEditor extends PureComponent<Props> {
layer.reinitializeMoveable();
};
onSelect = (item: any) => {
onSelect = (item: ElementState) => {
const { settings } = this.props.item;
if (settings?.scene) {