Skip to content

Commit

Permalink
Fixed view reset on view change (#6897)
Browse files Browse the repository at this point in the history
Fixes #6833 

The view states for unsaved changes were not reseted on view change.

The fix was to just add a call to the existing resetCurrentView when the
viewId changes in the related effect.
  • Loading branch information
lucasbordeau authored Sep 5, 2024
1 parent a2b1062 commit caff652
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilte
import { useViewFromQueryParams } from '@/views/hooks/internal/useViewFromQueryParams';
import { useViewStates } from '@/views/hooks/internal/useViewStates';
import { useGetCurrentView } from '@/views/hooks/useGetCurrentView';
import { useResetCurrentView } from '@/views/hooks/useResetCurrentView';
import { isUndefined } from '@sniptt/guards';
import { useEffect } from 'react';
import { useRecoilState } from 'recoil';
Expand Down Expand Up @@ -33,6 +34,14 @@ export const QueryParamsViewIdEffect = () => {
lastVisitedObjectMetadataItemId,
);

const { resetCurrentView } = useResetCurrentView();

useEffect(() => {
if (isDefined(currentViewId)) {
resetCurrentView();
}
}, [resetCurrentView, currentViewId]);

useEffect(() => {
const indexView = viewsOnCurrentObject.find((view) => view.key === 'INDEX');

Expand Down

0 comments on commit caff652

Please sign in to comment.