From b3d05b42e9b0afd8b4e828bdf57eb564a53e613f Mon Sep 17 00:00:00 2001 From: Innei Date: Mon, 16 Sep 2024 22:28:31 +0800 Subject: [PATCH] fix: radix auto focus issue Signed-off-by: Innei --- .../src/components/ui/modal/stacked/modal.tsx | 14 ++++++++++++-- .../src/components/ui/modal/stacked/types.tsx | 2 ++ src/renderer/src/modules/ai/ai-daily/daily.tsx | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/components/ui/modal/stacked/modal.tsx b/src/renderer/src/components/ui/modal/stacked/modal.tsx index fc1ff77c1..2b8fc2927 100644 --- a/src/renderer/src/components/ui/modal/stacked/modal.tsx +++ b/src/renderer/src/components/ui/modal/stacked/modal.tsx @@ -67,6 +67,7 @@ export const ModalInternal = memo( resizeable = false, resizeDefaultSize, modal = true, + autoFocus = true, } = item const setStack = useSetAtom(modalStackAtom) @@ -243,6 +244,15 @@ export const ModalInternal = memo( }, [canClose, clickOutsideToDismiss, dismiss, modal, noticeModal], ) + + const openAutoFocus = useCallback( + (event: Event) => { + if (!autoFocus) { + event.preventDefault() + } + }, + [autoFocus], + ) useImperativeHandle(ref, () => modalElementRef.current!) if (CustomModalComponent) { return ( @@ -250,7 +260,7 @@ export const ModalInternal = memo( {title} - +
- +
(props: LinkProps } else { present({ ...basePresentProps, - + autoFocus: false, modalClassName: "relative mx-auto mt-[10vh] scrollbar-none max-w-full overflow-auto px-2 lg:max-w-[65rem] lg:p-0", // eslint-disable-next-line @eslint-react/no-nested-components