@@ -35,19 +35,21 @@ export function EditIpPoolSideModalForm() {
3535 const { data : pool } = usePrefetchedApiQuery ( 'ipPoolView' , { path : poolSelector } )
3636
3737 const form = useForm ( { defaultValues : pool } )
38- const onDismiss = ( ) => navigate ( pb . ipPool ( { pool : poolSelector . pool } ) )
3938
4039 const editPool = useApiMutation ( 'ipPoolUpdate' , {
41- onSuccess ( _pool ) {
40+ onSuccess ( updatedPool ) {
4241 queryClient . invalidateQueries ( 'ipPoolList' )
43- if ( pool . name !== _pool . name ) {
44- // as the pool's name has changed, we need to navigate to an updated URL
45- navigate ( pb . ipPool ( { pool : _pool . name } ) )
46- } else {
42+ navigate ( pb . ipPool ( { pool : updatedPool . name } ) )
43+ addToast ( { content : 'Your IP pool has been updated' } )
44+
45+ // Only invalidate if we're staying on the same page. If the name
46+ // _has_ changed, invalidating ipPoolView causes an error page to flash
47+ // while the loader for the target page is running because the current
48+ // page's pool gets cleared out while we're still on the page. If we're
49+ // navigating to a different page, its query will fetch anew regardless.
50+ if ( pool . name === updatedPool . name ) {
4751 queryClient . invalidateQueries ( 'ipPoolView' )
48- onDismiss ( )
4952 }
50- addToast ( { content : 'Your IP pool has been updated' } )
5153 } ,
5254 } )
5355
@@ -56,7 +58,7 @@ export function EditIpPoolSideModalForm() {
5658 form = { form }
5759 formType = "edit"
5860 resourceName = "IP pool"
59- onDismiss = { onDismiss }
61+ onDismiss = { ( ) => navigate ( pb . ipPool ( { pool : poolSelector . pool } ) ) }
6062 onSubmit = { ( { name, description } ) => {
6163 editPool . mutate ( { path : poolSelector , body : { name, description } } )
6264 } }
0 commit comments