Просмотр исходного кода

🐛 fix(ratio-sync): reset pagination when filter/search changes

Add a `useEffect` hook in `UpstreamRatioSync.js` to automatically set
`currentPage` to `1` whenever `ratioTypeFilter` or `searchKeyword`
updates.
This prevents the table from appearing empty when users switch to the
“model_price” (fixed price) filter or perform a new search while on a
later page.

Additional changes:
- Import `useEffect` from React.

This enhancement delivers a smoother UX by ensuring the first page of
results is always shown after any filtering action.
t0ng7u 8 месяцев назад
Родитель
Сommit
c28190316f

+ 1 - 0
web/src/pages/Setting/Ratio/ModelSettingsVisualEditor.js

@@ -455,6 +455,7 @@ export default function ModelSettingsVisualEditor(props) {
               setCurrentPage(1);
             }}
             style={{ width: 200 }}
+            showClear
           />
           <Checkbox
             checked={conflictOnly}

+ 5 - 1
web/src/pages/Setting/Ratio/UpstreamRatioSync.js

@@ -1,4 +1,4 @@
-import React, { useState, useCallback, useMemo } from 'react';
+import React, { useState, useCallback, useMemo, useEffect } from 'react';
 import {
   Button,
   Table,
@@ -58,6 +58,10 @@ export default function UpstreamRatioSync(props) {
 
   const channelSelectorRef = React.useRef(null);
 
+  useEffect(() => {
+    setCurrentPage(1);
+  }, [ratioTypeFilter, searchKeyword]);
+
   const fetchAllChannels = async () => {
     setLoading(true);
     try {