From 82f2272e6a434929a65b21ec839855fcd8232dc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Fri, 1 Nov 2024 22:12:55 -0400 Subject: [PATCH] allow toggling editing state by double clicking on textarea/input element --- src/ui/fields/editable.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ui/fields/editable.tsx b/src/ui/fields/editable.tsx index 14446645..3cf70e2d 100644 --- a/src/ui/fields/editable.tsx +++ b/src/ui/fields/editable.tsx @@ -353,7 +353,7 @@ export function TextEditable(props: EditableState & { markdown?: boolean (e: MouseEvent) => { dispatch({ type: "editing-toggled", - newValue: true, + newValue: !state.isEditing, }); }, [text.current, props.sourcePath, state.updater, state.isEditing, state.content] @@ -368,7 +368,7 @@ export function TextEditable(props: EditableState & { markdown?: boolean ); const editor = ( - + ); return ( @@ -382,11 +382,13 @@ export function UncontrolledTextEditable({ text, dispatch, onInput, + toggler }: { inline?: boolean; text: string; dispatch?: Dispatch>; onInput?: (e: KeyboardEvent) => unknown; + toggler?: (e: MouseEvent) => void; }) { const [txt, setText] = useState(text); useEffect(() => { @@ -400,11 +402,11 @@ export function UncontrolledTextEditable({ ); return !inline ? ( - ) : ( - + ); } /** An editable list of items.