From e2d12f4fdd6b5a1c719947713ab72288d978436f Mon Sep 17 00:00:00 2001 From: wahiche-ideal <58079759+wahiche-ideal@users.noreply.github.com> Date: Fri, 26 Jan 2024 22:20:50 -0500 Subject: [PATCH] feat: Support document.activeElement (#393) Co-authored-by: huangbangsheng --- src/Dialog/Content/Panel.tsx | 12 +- tests/__snapshots__/index.spec.tsx.snap | 172 +++++++++++++----------- tests/index.spec.tsx | 41 +++--- 3 files changed, 127 insertions(+), 98 deletions(-) diff --git a/src/Dialog/Content/Panel.tsx b/src/Dialog/Content/Panel.tsx index 2aa492af..2be44237 100644 --- a/src/Dialog/Content/Panel.tsx +++ b/src/Dialog/Content/Panel.tsx @@ -6,6 +6,7 @@ import type { IDialogPropTypes } from '../../IDialogPropTypes'; import MemoChildren from './MemoChildren'; const sentinelStyle = { width: 0, height: 0, overflow: 'hidden', outline: 'none' }; +const entityStyle = { outline: 'none' }; export interface PanelProps extends Omit { prefixCls: string; @@ -53,10 +54,11 @@ const Panel = React.forwardRef((props, ref) => { const sentinelStartRef = useRef(); const sentinelEndRef = useRef(); + const entityRef = useRef(); React.useImperativeHandle(ref, () => ({ focus: () => { - sentinelStartRef.current?.focus(); + entityRef.current?.focus(); }, changeActive: (next) => { const { activeElement } = document; @@ -130,9 +132,11 @@ const Panel = React.forwardRef((props, ref) => { onMouseUp={onMouseUp} >