Skip to content

Commit

Permalink
fix: modal aria error
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Nov 11, 2024
1 parent b0d9309 commit 8884572
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions components/vc-dialog/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,14 +28,14 @@ export default defineComponent({
const dialogRef = ref<HTMLDivElement>();
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 });
}
},
});
Expand Down Expand Up @@ -143,9 +143,10 @@ export default defineComponent({
onMousedown={onMousedown}
onMouseup={onMouseup}
>
<div tabindex={0} ref={sentinelStartRef} style={sentinelStyle} inert/>
{modalRender ? modalRender({ originVNode: content }) : content}
<div tabindex={0} ref={sentinelEndRef} style={sentinelStyle} inert/>
<div tabindex={0} ref={sentinelStartRef} style={entityStyle}>
{modalRender ? modalRender({ originVNode: content }) : content}
</div>
<div tabindex={0} ref={sentinelEndRef} style={sentinelStyle} />
</div>
) : null}
</Transition>
Expand Down

0 comments on commit 8884572

Please sign in to comment.