Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 8 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"compile-less-cli": "~1.8.11",
"husky": "~8.0.0",
"kkt": "~7.3.0",
"lerna": "^6.0.0",
"lerna": "~6.0.0",
"lint-staged": "^13.0.3",
"prettier": "~2.8.0",
"react": "~18.2.0",
Expand Down
1 change: 0 additions & 1 deletion packages/react-date-picker/src/DatePickerYear.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export function DatePickerYear(props: DatePickerYearProps) {
const date = new Date(activeYear!);
date.setFullYear(year);
setActiveYear(date);
onSelected!(year, true);
} else {
onSelected!(year);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-date-picker/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export default function DatePicker(props: DatePickerProps) {
{type === 'time' && (
<TimePickerTime
date={selectPanelDate}
{...showTime}
{...(showTime as any)}
className={`${prefixCls}-timepicker`}
onSelected={onSelectedTime}
/>
Expand Down
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