Fix a bug in element selection and revert drag functionality

This commit is contained in:
Gasim Gasimzada 2020-01-09 19:20:21 +04:00
parent 1b9572fcc0
commit 3d855dabb6

View file

@ -775,8 +775,13 @@ export class App extends React.Component<{}, AppState> {
document.documentElement.style.cursor = `${resizeHandle}-resize`;
isResizingElements = true;
} else {
const selected = getElementAtPosition(
elements.filter(el => el.isSelected),
x,
y
);
// clear selection if shift is not clicked
if (!e.shiftKey) {
if (!selected && !e.shiftKey) {
elements = clearSelection(elements);
}
const hitElement = getElementAtPosition(elements, x, y);
@ -787,7 +792,7 @@ export class App extends React.Component<{}, AppState> {
// if shift is not clicked, this will always return true
// otherwise, it will trigger selection based on current
// state of the box
hitElement.isSelected = !hitElement.isSelected;
hitElement.isSelected = true;
// No matter what, we select it
// We duplicate the selected element if alt is pressed on Mouse down