Skip to content
Snippets Groups Projects
Commit e6d459fa authored by Anthony's avatar Anthony
Browse files

Finish state moving

parent c358bf36
No related branches found
No related tags found
1 merge request!10Draft: MigratingAnnotationCreation to MUI5.
Pipeline #1898 failed
...@@ -142,19 +142,22 @@ function AnnotationDrawing({ drawingState, setDrawingState, ...props }) { ...@@ -142,19 +142,22 @@ function AnnotationDrawing({ drawingState, setDrawingState, ...props }) {
e.stopPropagation(); e.stopPropagation();
const unnalowedKeys = ['Shift', 'Control', 'Alt', 'Meta', 'Enter', 'Escape', 'Tab', 'AltGraph', 'CapsLock', 'NumLock', 'ScrollLock', 'Pause', 'Insert', 'Home', 'PageUp', 'PageDown', 'End', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ContextMenu', 'PrintScreen', 'Help', 'Clear', 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12', 'OS']; const unnalowedKeys = ['Shift', 'Control', 'Alt', 'Meta', 'Enter', 'Escape', 'Tab', 'AltGraph', 'CapsLock', 'NumLock', 'ScrollLock', 'Pause', 'Insert', 'Home', 'PageUp', 'PageDown', 'End', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ContextMenu', 'PrintScreen', 'Help', 'Clear', 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12', 'OS'];
if (!currentShape) { if (!drawingState.currentShape) {
return; return;
} }
if (e.key === 'Delete') { if (e.key === 'Delete') {
const newShapes = shapes.filter((shape) => shape.id !== currentShape.id); const shapesWithoutTheDeleted = drawingState.shapes.filter((shape) => shape.id !== drawingState.currentShape.id);
setShapes(newShapes); setDrawingState({
...drawingState,
shapes: shapesWithoutTheDeleted,
});
return; return;
} }
// TODO This comportment must be handle by the text component // TODO This comportment must be handle by the text component
if (currentShape.type === 'text') { if (drawingState.currentShape.type === 'text') {
let newText = currentShape.text; let newText = drawingState.currentShape.text;
if (e.key === 'Backspace') { if (e.key === 'Backspace') {
newText = newText.slice(0, -1); newText = newText.slice(0, -1);
} else { } else {
...@@ -164,14 +167,14 @@ function AnnotationDrawing({ drawingState, setDrawingState, ...props }) { ...@@ -164,14 +167,14 @@ function AnnotationDrawing({ drawingState, setDrawingState, ...props }) {
newText += e.key; newText += e.key;
} }
// TODO Check // Potentially bug during the update
/* setCurrentShape({ ...currentShape, text: newText }); */ const newCurrentShape = { ...drawingState.currentShape, text: newText };
const newCurrentShape = { ...currentShape, text: newText };
setCurrentShape(newCurrentShape);
// setShapes(shapes.map((shape) => (shape.id === currentShape.id ? currentShape : shape))); setDrawingState({
const newShapes = shapes.map((shape) => (shape.id === currentShape.id ? newCurrentShape : shape)); ...drawingState,
setShapes(newShapes); shapes: shapes.map((shape) => (shape.id === drawingState.currentShape.id ? newCurrentShape : shape)),
currentShape: newCurrentShape,
});
} }
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment