From a318a046414499fd3cffe5701ace81f429e2432b Mon Sep 17 00:00:00 2001 From: Jeremy Scatigna Date: Wed, 8 Jan 2020 16:09:59 +0100 Subject: [PATCH] feat(duplicate_element): make it work even if element is already selected --- src/index.tsx | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 35a527c67..022d026ad 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -671,26 +671,26 @@ class App extends React.Component<{}, AppState> { if (!e.shiftKey) { clearSelection(elements); } - // We duplicate the selected element if alt is pressed on Mouse down - if (e.altKey) { - const element = newElement( - hitElement.type, - hitElement.x, - hitElement.y, - hitElement.strokeColor, - hitElement.backgroundColor, - hitElement.fillStyle, - hitElement.strokeWidth, - hitElement.roughness, - hitElement.opacity, - hitElement.width, - hitElement.height - ); + } + // No matter what, we select it + hitElement.isSelected = true; + // We duplicate the selected element if alt is pressed on Mouse down + if (e.altKey) { + const element = newElement( + hitElement.type, + hitElement.x, + hitElement.y, + hitElement.strokeColor, + hitElement.backgroundColor, + hitElement.fillStyle, + hitElement.strokeWidth, + hitElement.roughness, + hitElement.opacity, + hitElement.width, + hitElement.height + ); - elements.push(element); - } - // No matter what, we select it - hitElement.isSelected = true; + elements.push(element); } } else { // If we don't click on anything, let's remove all the selected elements