Commit 1b31673d authored by Michael Vrána's avatar Michael Vrána

Node delete not deselecting fix

parent 1502e415
Pipeline #80291 passed with stages
in 5 minutes and 2 seconds
......@@ -105,18 +105,12 @@ export const AlgorithmCanvasToolbar = () => {
const handleUndo = useCallback(() => dispatch(undoAlgorithm()), [dispatch])
const handleRedo = useCallback(() => dispatch(redoAlgorithm()), [dispatch])
const handleClear = useCallback(() => dispatch(clear()), [dispatch])
const handleToggleHint = useCallback(() => dispatch(toggleHint()), [dispatch])
const handleToggleHint = useCallback(() => dispatch(toggleHint()), [
dispatch
])
return (
<div className={classes.root}>
<Paper>
<ElementButton
Icon={DeleteIcon}
label="Delete selected"
isDisabled={!elementSelected}
onAction={handleDelete}
/>
</Paper>
<CanvasToolbar
cursorMode={cursorMode}
gridOn={gridOn}
......@@ -127,6 +121,12 @@ export const AlgorithmCanvasToolbar = () => {
onGrid={handleGridToggle}
/>
<Paper>
<ElementButton
Icon={DeleteIcon}
label="Delete selected"
isDisabled={!elementSelected}
onAction={handleDelete}
/>
<ElementButton
Icon={UndoIcon}
label="Undo"
......
import { canvasActionsFactory, canvasReducerFactory, CanvasState, initialState } from './canvas'
import {
canvasActionsFactory,
canvasReducerFactory,
CanvasState,
initialState
} from './canvas'
import { undoAlgorithmActionType, redoAlgorithmActionType } from '.'
export type AlgorithmCanvasState = CanvasState
......@@ -8,4 +14,23 @@ export const initialAlgorithmCanvasState = initialState
export const algorithmCanvasActions = canvasActionsFactory(algorithmCanvasId)
export const algorithmCanvasReducer = canvasReducerFactory(algorithmCanvasId)
const canvasReducer = canvasReducerFactory(algorithmCanvasId)
export const algorithmCanvasReducer = (
state: AlgorithmCanvasState = initialState,
action: any
) => {
let newState = canvasReducer(state, action)
if (
[
undoAlgorithmActionType,
redoAlgorithmActionType,
'deleteNode',
'deleteEdge'
].includes(action.type)
)
newState = { ...newState, selectedEdge: '', selectedNode: '' }
return newState
}
......@@ -44,10 +44,10 @@ import {
initialAlgorithmUIState
} from './algorithmUI'
const undoStatemakerActionType = 'undoStatemaker'
const redoStatemakerActionType = 'redoStatemaker'
const undoAlgorithmActionType = 'undoAlgorithm'
const redoAlgorithmActionType = 'redoAlgorithm'
export const undoStatemakerActionType = 'undoStatemaker'
export const redoStatemakerActionType = 'redoStatemaker'
export const undoAlgorithmActionType = 'undoAlgorithm'
export const redoAlgorithmActionType = 'redoAlgorithm'
export const Actions = {
...stateCanvasActions,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment