mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
fix(board): unable to create by clicking outside
This commit is contained in:
parent
94e20c44e5
commit
3b06845a71
@ -228,7 +228,7 @@ export function TitleEditor({ currentValue, placeholder, save, dismiss, multilin
|
|||||||
}) {
|
}) {
|
||||||
const inputRef = useRef<any>(null);
|
const inputRef = useRef<any>(null);
|
||||||
const dismissOnNextRefreshRef = useRef(false);
|
const dismissOnNextRefreshRef = useRef(false);
|
||||||
const shouldSave = useRef(false);
|
const shouldDismiss = useRef(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
inputRef.current?.focus();
|
inputRef.current?.focus();
|
||||||
@ -254,12 +254,12 @@ export function TitleEditor({ currentValue, placeholder, save, dismiss, multilin
|
|||||||
onKeyDown={(e: TargetedKeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {
|
onKeyDown={(e: TargetedKeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {
|
||||||
if (e.key === "Enter" || e.key === "Escape") {
|
if (e.key === "Enter" || e.key === "Escape") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
shouldSave.current = (e.key === "Enter");
|
shouldDismiss.current = (e.key === "Escape");
|
||||||
e.currentTarget.blur();
|
e.currentTarget.blur();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onBlur={(newValue) => {
|
onBlur={(newValue) => {
|
||||||
if (shouldSave.current && newValue.trim() && (newValue !== currentValue || isNewItem)) {
|
if (!shouldDismiss.current && newValue.trim() && (newValue !== currentValue || isNewItem)) {
|
||||||
save(newValue);
|
save(newValue);
|
||||||
dismissOnNextRefreshRef.current = true;
|
dismissOnNextRefreshRef.current = true;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user