diff --git a/src/actions/formatLetterCase.ts b/src/actions/formatLetterCase.ts index 053633e387..06ce3e343c 100644 --- a/src/actions/formatLetterCase.ts +++ b/src/actions/formatLetterCase.ts @@ -16,18 +16,18 @@ export const formatLetterCaseActionCreator = const cursor = state.cursor if (!cursor) return - const originalThoughtValue = pathToThought(state, cursor)?.value - if (originalThoughtValue === undefined) return + const thought = pathToThought(state, cursor) + if (!thought) return state - const updatedThoughtValue = applyLetterCase(command, originalThoughtValue) + const oldValue = thought.value + const newValue = applyLetterCase(command, oldValue) const simplePath = simplifyPath(state, cursor) - const offset = selection.offsetThought() dispatch( editThought({ - oldValue: originalThoughtValue, - newValue: updatedThoughtValue, + oldValue, + newValue, path: simplePath, force: true, }), diff --git a/src/hooks/useDragAndDropSubThought.ts b/src/hooks/useDragAndDropSubThought.ts index 5074aac0ce..372f3b2b97 100644 --- a/src/hooks/useDragAndDropSubThought.ts +++ b/src/hooks/useDragAndDropSubThought.ts @@ -115,7 +115,7 @@ const drop = (props: DroppableSubthoughts, monitor: DropTargetMonitor) => { const dropTop = !isExpanded && attributeEquals(state, parentIdTo, '=drop', 'top') // cannot drop on itself - if (equalPath(thoughtsFrom, props.simplePath)) return + if (!thoughtFrom || !thoughtTo || equalPath(thoughtsFrom, props.simplePath)) return // cannot move root or em context or target is divider if (isDivider(thoughtTo?.value) || (isRootOrEM && !sameContext)) { @@ -125,11 +125,6 @@ const drop = (props: DroppableSubthoughts, monitor: DropTargetMonitor) => { return } - if (!thoughtTo) { - console.warn(`Cannot drop ${thoughtFrom} on itself. Aborting drop.`) - return - } - store.dispatch( moveThought({ oldPath: thoughtsFrom, @@ -139,7 +134,7 @@ const drop = (props: DroppableSubthoughts, monitor: DropTargetMonitor) => { ) // alert user of move to another context - if (!sameContext && thoughtTo && thoughtFrom) { + if (!sameContext) { // wait until after MultiGesture has cleared the error so this alert does no get cleared setTimeout(() => { const alertFrom = '"' + ellipsize(thoughtFrom.value) + '"'