Fixed delete confirmation popping up while clicking backspace on canvas (#2504)

This commit is contained in:
Shaurya Sharma 2024-10-25 12:39:14 +05:30 committed by Shaurya Sharma
parent 44ff38cc10
commit ed75923193

View file

@ -45,6 +45,13 @@ export const HotkeyProvider = ({ children, mode, currentLayout, canvasMaxWidth }
}
};
const deleteComponents = () => {
const selectedComponents = getSelectedComponents();
if (selectedComponents.length > 0) {
setWidgetDeleteConfirmation(true);
}
};
useEffect(() => {
const handleClick = (e) => {
const modalContainer = document.getElementById('modal-container');
@ -91,7 +98,7 @@ export const HotkeyProvider = ({ children, mode, currentLayout, canvasMaxWidth }
handleEscapeKeyPress(); // clears the selected components
break;
case 'Backspace':
setWidgetDeleteConfirmation(true); // Delete opration -> First asks for a Confirmation
deleteComponents(); // Delete opration -> First asks for a Confirmation
break;
case 'KeyD':
copyComponents({ isCloning: true }); // Clone/Duplicate operation