fix(dialog): prevent scroll to top on modal close (#318)

* fix(dialog): prevent both open and close auto focus to avoid page scroll

Add onOpenAutoFocus handler to prevent Radix Dialog from auto-focusing
content on open, which can cause unwanted scroll behavior.

* fix(dialog): remove onOpenAutoFocus, keep only onCloseAutoFocus

Remove onOpenAutoFocus handler that was causing scroll issues on first open.
Keep onCloseAutoFocus to prevent scroll to trigger element on close.

Key fix: Move {...props} before onCloseAutoFocus to prevent override.

* fix(dialog): prevent scroll to top on modal close

- Move {...props} before onCloseAutoFocus to prevent override
- Simplify handler to just e.preventDefault()
- Apply fix to both dialog.tsx and modal.tsx
This commit is contained in:
sagit
2026-03-14 10:32:35 +08:00
committed by GitHub
parent 05c3b5842e
commit e56dd898ef
156 changed files with 294 additions and 167452 deletions
+4 -3
View File
@@ -381,7 +381,7 @@ export default function TunnelPage() {
});
setErrors({});
setModalOpen(true);
};
};
// 删除隧道
const handleDelete = (tunnel: Tunnel) => {
@@ -918,7 +918,9 @@ export default function TunnelPage() {
failures,
);
} else {
toast.error(`成功 ${result.successCount} 项,失败 ${result.failCount} 项`);
toast.error(
`成功 ${result.successCount} 项,失败 ${result.failCount} 项`,
);
}
setBatchProgress({
active: true,
@@ -1413,7 +1415,6 @@ export default function TunnelPage() {
</div>
)}
</div>
</div>
<div className="flex gap-1.5 mt-3">