From 5e592c66c7b0d63d7a9881bf06c557d3eacdfec9 Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Sun, 7 Sep 2025 19:44:53 +0100 Subject: [PATCH] Added clear action. --- src/components/Dashboard/common/ActionHandler.jsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/Dashboard/common/ActionHandler.jsx b/src/components/Dashboard/common/ActionHandler.jsx index fa707cd..8e0c65e 100644 --- a/src/components/Dashboard/common/ActionHandler.jsx +++ b/src/components/Dashboard/common/ActionHandler.jsx @@ -30,6 +30,15 @@ const ActionHandler = forwardRef( navigate(newPath, { replace: true }) } + // Method to clear current action from URL + const clearAction = () => { + const searchParams = new URLSearchParams(location.search) + searchParams.delete(actionParam) + const newSearch = searchParams.toString() + const newPath = location.pathname + (newSearch ? `?${newSearch}` : '') + navigate(newPath, { replace: true }) + } + // Execute action and clear from URL useEffect(() => { if ( @@ -72,7 +81,8 @@ const ActionHandler = forwardRef( ]) useImperativeHandle(ref, () => ({ - callAction + callAction, + clearAction })) // Return null as this is a utility component