diff --git a/packages/react-overlay-trigger/src/index.tsx b/packages/react-overlay-trigger/src/index.tsx index 52899dc593..7d52f7a4cd 100644 --- a/packages/react-overlay-trigger/src/index.tsx +++ b/packages/react-overlay-trigger/src/index.tsx @@ -251,13 +251,22 @@ export default React.forwardRef((props, function hide() { if (!isOpen) return; - zIndex.current -= 1; + if (zIndex.current <= 999) { + zIndex.current = 999; + } else { + zIndex.current -= 1; + } setIsOpen(false); } function show() { if (isOpen) return; - zIndex.current += 1; + const nodeIndex = triggerRef.current?.style.zIndex; + if (nodeIndex) { + zIndex.current = Number(nodeIndex) + 1; + } else { + zIndex.current += 1; + } setIsOpen(true); } @@ -305,6 +314,7 @@ export default React.forwardRef((props, Object.assign({}, child.props, { ...triggerProps, ref: triggerRef, + style: { zIndex: zIndex.current }, className: [child.props.className, disabled ? `${prefixCls}-disabled` : null] .filter(Boolean) .join(' ') diff --git a/website/src/layouts/index.module.less b/website/src/layouts/index.module.less index cb00a69ab5..2714ebfa9d 100755 --- a/website/src/layouts/index.module.less +++ b/website/src/layouts/index.module.less @@ -22,6 +22,8 @@ } .layoutWrap { + position: relative; + z-index: 1; background-color: #fff; min-height: calc(100vh - 53px); }