Skip to content

Commit

Permalink
fix(OverlayTrigger): 修复嵌套弹出导致元素层级异常 (#960)
Browse files Browse the repository at this point in the history
* fix: 修复table展示问题

* fix: 修复table宽度

* fix(DatePicker): 修复日历年份选择异常

* chore(deps): update dependency lerna to v6.0.0

* fix(OverlayTrigger): 修复嵌套弹出导致元素层级异常

* remove other class
  • Loading branch information
yaob421123 authored Apr 20, 2023
1 parent b13cb92 commit 173a08d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/react-overlay-trigger/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,22 @@ export default React.forwardRef<OverlayTriggerRef, OverlayTriggerProps>((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);
}

Expand Down Expand Up @@ -305,6 +314,7 @@ export default React.forwardRef<OverlayTriggerRef, OverlayTriggerProps>((props,
Object.assign({}, child.props, {
...triggerProps,
ref: triggerRef,
style: { zIndex: zIndex.current },
className: [child.props.className, disabled ? `${prefixCls}-disabled` : null]
.filter(Boolean)
.join(' ')
Expand Down
2 changes: 2 additions & 0 deletions website/src/layouts/index.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
}

.layoutWrap {
position: relative;
z-index: 1;
background-color: #fff;
min-height: calc(100vh - 53px);
}
Expand Down

0 comments on commit 173a08d

Please sign in to comment.