From 888457238d99faa59308aa65cae21c81ab6a1607 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Mon, 11 Nov 2024 14:40:49 +0800 Subject: [PATCH] fix: modal aria error --- components/vc-dialog/Content.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/components/vc-dialog/Content.tsx b/components/vc-dialog/Content.tsx index ad2761384..7c1a5fe60 100644 --- a/components/vc-dialog/Content.tsx +++ b/components/vc-dialog/Content.tsx @@ -5,7 +5,7 @@ import { getTransitionProps } from '../_util/transition'; import dialogPropTypes from './IDialogPropTypes'; import { offset } from './util'; const sentinelStyle = { width: 0, height: 0, overflow: 'hidden', outline: 'none' }; - +const entityStyle = { outline: 'none' }; export type ContentRef = { focus: () => void; changeActive: (next: boolean) => void; @@ -28,14 +28,14 @@ export default defineComponent({ const dialogRef = ref(); expose({ focus: () => { - sentinelStartRef.value?.focus(); + sentinelStartRef.value?.focus({ preventScroll: true }); }, changeActive: next => { const { activeElement } = document; if (next && activeElement === sentinelEndRef.value) { - sentinelStartRef.value.focus(); + sentinelStartRef.value.focus({ preventScroll: true }); } else if (!next && activeElement === sentinelStartRef.value) { - sentinelEndRef.value.focus(); + sentinelEndRef.value.focus({ preventScroll: true }); } }, }); @@ -143,9 +143,10 @@ export default defineComponent({ onMousedown={onMousedown} onMouseup={onMouseup} > -
- {modalRender ? modalRender({ originVNode: content }) : content} -
+
+ {modalRender ? modalRender({ originVNode: content }) : content} +
+
) : null}