Added clear action.
This commit is contained in:
parent
9fe2b60d04
commit
5e592c66c7
@ -30,6 +30,15 @@ const ActionHandler = forwardRef(
|
|||||||
navigate(newPath, { replace: true })
|
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
|
// Execute action and clear from URL
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
@ -72,7 +81,8 @@ const ActionHandler = forwardRef(
|
|||||||
])
|
])
|
||||||
|
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
callAction
|
callAction,
|
||||||
|
clearAction
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// Return null as this is a utility component
|
// Return null as this is a utility component
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user