feature/IO-3603-Production-Board-Note-Autofocus - Fix
This commit is contained in:
@@ -12,6 +12,7 @@ export default function ProductionListColumnComment({ record, usePortal = false
|
||||
const [note, setNote] = useState(record.comment || "");
|
||||
const [open, setOpen] = useState(false);
|
||||
const textAreaRef = useRef(null);
|
||||
const rafIdRef = useRef(null);
|
||||
|
||||
const [updateAlert] = useMutation(UPDATE_JOB);
|
||||
|
||||
@@ -37,14 +38,21 @@ export default function ProductionListColumnComment({ record, usePortal = false
|
||||
};
|
||||
|
||||
const handleOpenChange = (flag) => {
|
||||
if (rafIdRef.current) {
|
||||
cancelAnimationFrame(rafIdRef.current);
|
||||
rafIdRef.current = null;
|
||||
}
|
||||
setOpen(flag);
|
||||
if (flag) {
|
||||
setNote(record.comment || "");
|
||||
requestAnimationFrame(() => {
|
||||
try {
|
||||
textAreaRef.current?.focus?.({ preventScroll: true });
|
||||
} catch {
|
||||
textAreaRef.current?.focus?.();
|
||||
rafIdRef.current = requestAnimationFrame(() => {
|
||||
rafIdRef.current = null;
|
||||
if (textAreaRef.current?.focus) {
|
||||
try {
|
||||
textAreaRef.current.focus({ preventScroll: true });
|
||||
} catch {
|
||||
textAreaRef.current.focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ function ProductionListColumnProductionNote({ record, setNoteUpsertContext, useP
|
||||
const [note, setNote] = useState(record.production_vars?.note || "");
|
||||
const [open, setOpen] = useState(false);
|
||||
const textAreaRef = useRef(null);
|
||||
const rafIdRef = useRef(null);
|
||||
|
||||
const [updateAlert] = useMutation(UPDATE_JOB);
|
||||
|
||||
@@ -53,14 +54,21 @@ function ProductionListColumnProductionNote({ record, setNoteUpsertContext, useP
|
||||
|
||||
const handleOpenChange = useCallback(
|
||||
(flag) => {
|
||||
if (rafIdRef.current) {
|
||||
cancelAnimationFrame(rafIdRef.current);
|
||||
rafIdRef.current = null;
|
||||
}
|
||||
setOpen(flag);
|
||||
if (flag) {
|
||||
setNote(record.production_vars?.note || "");
|
||||
requestAnimationFrame(() => {
|
||||
try {
|
||||
textAreaRef.current?.focus?.({ preventScroll: true });
|
||||
} catch {
|
||||
textAreaRef.current?.focus?.();
|
||||
rafIdRef.current = requestAnimationFrame(() => {
|
||||
rafIdRef.current = null;
|
||||
if (textAreaRef.current?.focus) {
|
||||
try {
|
||||
textAreaRef.current.focus({ preventScroll: true });
|
||||
} catch {
|
||||
textAreaRef.current.focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user