feat(duplicate_element): make it work even if element is already selected

This commit is contained in:
Jeremy Scatigna 2020-01-08 16:09:59 +01:00
parent 2eff4779a4
commit a318a04641

View file

@ -671,26 +671,26 @@ class App extends React.Component<{}, AppState> {
if (!e.shiftKey) { if (!e.shiftKey) {
clearSelection(elements); clearSelection(elements);
} }
// We duplicate the selected element if alt is pressed on Mouse down }
if (e.altKey) { // No matter what, we select it
const element = newElement( hitElement.isSelected = true;
hitElement.type, // We duplicate the selected element if alt is pressed on Mouse down
hitElement.x, if (e.altKey) {
hitElement.y, const element = newElement(
hitElement.strokeColor, hitElement.type,
hitElement.backgroundColor, hitElement.x,
hitElement.fillStyle, hitElement.y,
hitElement.strokeWidth, hitElement.strokeColor,
hitElement.roughness, hitElement.backgroundColor,
hitElement.opacity, hitElement.fillStyle,
hitElement.width, hitElement.strokeWidth,
hitElement.height hitElement.roughness,
); hitElement.opacity,
hitElement.width,
hitElement.height
);
elements.push(element); elements.push(element);
}
// No matter what, we select it
hitElement.isSelected = true;
} }
} else { } else {
// If we don't click on anything, let's remove all the selected elements // If we don't click on anything, let's remove all the selected elements