choo121600 commented on code in PR #54059:
URL: https://github.com/apache/airflow/pull/54059#discussion_r2250069928
##########
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:
I think I can use sessionStorage instead of localStorage.
That way, I might be able to avoid using useEffect. I’ll try it ;)
--
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]