Added clear action.
This commit is contained in:
parent
9fe2b60d04
commit
5e592c66c7
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user