Skip to content

Commit

Permalink
fix: hide empty record groups
Browse files Browse the repository at this point in the history
  • Loading branch information
magrinj committed Nov 28, 2024
1 parent 69e56eb commit 25c8312
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const useRecordGroupVisibility = ({
// If visibility is manually toggled, we should reset the hideEmptyRecordGroup state
set(objectOptionsDropdownRecordGroupHideState, false);
},
[objectOptionsDropdownRecordGroupHideState, saveViewGroup],
[saveViewGroup, objectOptionsDropdownRecordGroupHideState],
);

const handleHideEmptyRecordGroupChange = useRecoilCallback(
Expand All @@ -61,26 +61,34 @@ export const useRecordGroupVisibility = ({
snapshot,
objectOptionsDropdownRecordGroupHideState,
);
const newHideState = !currentHideState;

set(objectOptionsDropdownRecordGroupHideState, !currentHideState);
set(objectOptionsDropdownRecordGroupHideState, newHideState);

for (const recordGroupId of recordGroupIds) {
const recordGroup = getSnapshotValue(
snapshot,
recordGroupDefinitionFamilyState(recordGroupId),
);

if (!isDefined(recordGroup)) {
throw new Error(
`Record group with id ${recordGroupId} not found in snapshot`,
);
}

const recordGroupRowIds = getSnapshotValue(
snapshot,
recordIndexRowIdsByGroupFamilyState(recordGroupId),
);

if (!isDefined(recordGroup) || recordGroupRowIds.length > 0) {
if (recordGroupRowIds.length > 0) {
continue;
}

const updatedRecordGroup = {
...recordGroup,
isVisible: !currentHideState,
isVisible: !newHideState,
};

set(
Expand Down

0 comments on commit 25c8312

Please sign in to comment.