Modal, header, mobile display and workflow UI updates

This commit is contained in:
willchen96 2026-06-11 22:43:13 +08:00
parent 8a2dc05181
commit 3132e04ac0
34 changed files with 1635 additions and 1076 deletions

View file

@ -21,6 +21,7 @@ export function RenameableTitle({ value, onCommit, suffix }: Props) {
const [draft, setDraft] = useState("");
const caretPos = useRef<number | null>(null);
const escaped = useRef(false);
const committed = useRef(false);
function startEditing(e: React.MouseEvent) {
const doc = document as CaretDocument;
@ -32,15 +33,18 @@ export function RenameableTitle({ value, onCommit, suffix }: Props) {
? range.startOffset
: null;
escaped.current = false;
committed.current = false;
setDraft(value);
setEditing(true);
}
function commit() {
if (committed.current) return;
if (escaped.current) {
escaped.current = false;
return;
}
committed.current = true;
setEditing(false);
onCommit(draft.trim());
}
@ -58,9 +62,13 @@ export function RenameableTitle({ value, onCommit, suffix }: Props) {
value={draft}
onChange={(e) => setDraft(e.target.value)}
onKeyDown={(e) => {
if (e.key === "Enter") commit();
if (e.key === "Enter") {
e.preventDefault();
commit();
}
if (e.key === "Escape") {
escaped.current = true;
committed.current = true;
setEditing(false);
}
}}