Skip to content

Commit 6c507f4

Browse files
cyfung1031CodFrm
andauthored
🐛 修复弹出框被遮挡的问题 (#1290)
* fix getPopupContainer * 🐛 修复 pre-commit hook lint-fix 修改未加入暂存区的问题 * 🐛 修复运行日志页面日期选择弹出框被 overflow 容器裁剪的问题 * 🔧 修复 husky hook 可执行权限 --------- Co-authored-by: 王一之 <[email protected]>
1 parent 056bfab commit 6c507f4

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

.husky/pre-commit

100644100755
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
#!/bin/sh
22

3-
pnpm run lint-fix
3+
pnpm run lint-fix
4+
5+
# 将已暂存且被 lint-fix 修改过的文件重新加入暂存区
6+
STAGED=$(git diff --cached --name-only --diff-filter=d)
7+
CHANGED=$(git diff --name-only)
8+
9+
for file in $CHANGED; do
10+
case "$STAGED" in
11+
*"$file"*) git add "$file" ;;
12+
esac
13+
done

.husky/pre-push

100644100755
File mode changed.

src/pages/components/layout/MainLayout.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ const importByUrls = async (urls: string[]): Promise<TImportStat | undefined> =>
119119
return stat;
120120
};
121121

122+
const getSafePopupParent = (p: Element) => {
123+
p = (p.closest("button")?.parentNode as Element) || p; // 確保 ancestor 沒有 button 元素
124+
p = (p.closest("span")?.parentNode as Element) || p; // 確保 ancestor 沒有 span 元素
125+
p = (p.closest(".arco-collapse-item-content")?.parentNode as Element) || p; // 確保 ancestor 沒有 .arco-collapse-item-content 元素
126+
p = (p.closest("aside")?.parentNode as Element) || p; // 確保 ancestor 沒有 aside 元素
127+
return p;
128+
};
129+
122130
// --- 子组件:提取拖拽遮罩以优化性能 ---
123131
const DropzoneOverlay: React.FC<{ active: boolean; text: string }> = React.memo(({ active, text }) => {
124132
if (!active) return null;
@@ -297,16 +305,12 @@ const MainLayout: React.FC<{
297305
componentConfig={{
298306
Select: {
299307
getPopupContainer: (node) => {
300-
return node;
308+
return getSafePopupParent(node as Element);
301309
},
302310
},
303311
}}
304312
getPopupContainer={(node) => {
305-
let p = node.parentNode as Element;
306-
p = (p.closest("button")?.parentNode as Element) || p; // 確保 ancestor 沒有 button 元素
307-
p = (p.closest("span")?.parentNode as Element) || p; // 確保 ancestor 沒有 span 元素
308-
p = (p.closest("aside")?.parentNode as Element) || p; // 確保 ancestor 沒有 aside 元素
309-
return p;
313+
return getSafePopupParent(node.parentNode as Element);
310314
}}
311315
>
312316
{contextHolder}

src/pages/options/routes/Logger.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ function LoggerPage() {
133133
style={{ width: 400 }}
134134
showTime
135135
shortcutsPlacementLeft
136+
getPopupContainer={() => document.body}
136137
value={[startTime * 1000, endTime * 1000]}
137138
onChange={(_, time) => {
138139
setStartTime(time[0].unix());

0 commit comments

Comments
 (0)