choo121600 commented on code in PR #54059:
URL: https://github.com/apache/airflow/pull/54059#discussion_r2250074785


##########
airflow-core/src/airflow/ui/src/pages/DagsList/DagsList.tsx:
##########
@@ -203,16 +203,26 @@ export const DagsList = () => {
   const { setTableURLState, tableURLState } = useTableURLState();
 
   const { pagination, sorting } = tableURLState;
+  const [savedSearchPattern, setSavedSearchPattern] = 
useLocalStorage("dags_search_temp", "");
   const [dagDisplayNamePattern, setDagDisplayNamePattern] = useState(
-    searchParams.get(NAME_PATTERN) ?? undefined,
+    searchParams.get(NAME_PATTERN) ?? savedSearchPattern,
   );
 
+  useEffect(() => {
+    const handleBeforeUnload = () => setSavedSearchPattern("");
+
+    globalThis.addEventListener("beforeunload", handleBeforeUnload);
+
+    return () => globalThis.removeEventListener("beforeunload", 
handleBeforeUnload);
+  }, [setSavedSearchPattern]);
+

Review Comment:
   Using `sessionStorage` instead of `localStorage` + `beforeunload` makes it 
hard to clear the search term on refresh.
   But I think it’s a good trade-off to remove the reset-on-refresh behavior - 
better to keep it on refresh and clear it only when the session ends.
   What do you think?
   
   
https://github.com/user-attachments/assets/5fd4f96c-aac3-40fa-b346-bbb7ef6edcad



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to