mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-09 03:06:37 +08:00
fix: preserve scroll position after editing forward rules (#319)
* 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
* fix: preserve scroll position after editing forward rules
Move getForwardDisplayFlow outside component to prevent unnecessary
re-renders that reset scroll position on save.
This commit is contained in:
@@ -579,6 +579,16 @@ const mapForwardApiItems = (items: ForwardApiItem[]): Forward[] => {
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getForwardDisplayFlow = (forward: Forward): number => {
|
||||||
|
const directFlow = (forward.inFlow || 0) + (forward.outFlow || 0);
|
||||||
|
|
||||||
|
if (directFlow > 0) {
|
||||||
|
return directFlow;
|
||||||
|
}
|
||||||
|
|
||||||
|
return forward.federationShareFlow || 0;
|
||||||
|
};
|
||||||
|
|
||||||
export default function ForwardPage() {
|
export default function ForwardPage() {
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [forwards, setForwards] = useState<Forward[]>([]);
|
const [forwards, setForwards] = useState<Forward[]>([]);
|
||||||
@@ -1237,16 +1247,6 @@ export default function ForwardPage() {
|
|||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
const getForwardDisplayFlow = (forward: Forward): number => {
|
|
||||||
const directFlow = (forward.inFlow || 0) + (forward.outFlow || 0);
|
|
||||||
|
|
||||||
if (directFlow > 0) {
|
|
||||||
return directFlow;
|
|
||||||
}
|
|
||||||
|
|
||||||
return forward.federationShareFlow || 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 切换显示模式并保存到localStorage
|
// 切换显示模式并保存到localStorage
|
||||||
const handleViewModeChange = () => {
|
const handleViewModeChange = () => {
|
||||||
const newMode = viewMode === "grouped" ? "direct" : "grouped";
|
const newMode = viewMode === "grouped" ? "direct" : "grouped";
|
||||||
|
|||||||
Reference in New Issue
Block a user