Added clear action.

This commit is contained in:
Tom Butcher 2025-09-07 19:44:53 +01:00
parent 9fe2b60d04
commit 5e592c66c7

View File

@ -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