KeepAlive&AntdTimePicker
KeepAlive&AntdTimePicker
0. 缘起
操蛋的局部全屏组件fscreen
,antd的选择器下拉框灵魂仍然存在在原来未全屏的组件中。如果缓存多个页面,需要找到当前页面的父元素来匹配。
1. 找祖宗
部分下拉框需要特殊处理
从当前元素往上寻找bi-layout-canvas-track
的元素
getPopupContainer={trigger => getRightParentNode(trigger)}
const getRightParentNode = useCallback(
(trigger: HTMLElement) => {
let now = trigger.parentElement;
if (isFullScreen) {
const specialClassName = 'bi-layout-canvas-track';
while (!now?.className.includes(specialClassName)) {
if (now) {
now = now.parentElement;
}
}
return now || document.body;
}
return document.body;
},
[isFullScreen]
);
2. 找爸爸
日期选择器
getPopupContainer={trigger =>
trigger.parentElement || document.body
}
3.
人生到处知何似,应似飞鸿踏雪泥。