Merge pull request #8450 from backstage/timbonicus/avoid-updating-types

Skip updating selected types if they didn't change
This commit is contained in:
Ben Lambert
2021-12-13 11:28:28 +01:00
committed by GitHub
2 changed files with 9 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-react': patch
---
`useEntityTypeFilter`: Skip updating selected types if a kind filter change did not change them.
@@ -16,6 +16,7 @@
import { useEffect, useMemo, useRef, useState } from 'react';
import { useAsync } from 'react-use';
import isEqual from 'lodash/isEqual';
import { useApi } from '@backstage/core-plugin-api';
import { catalogApiRef } from '../api';
import { useEntityListProvider } from './useEntityListProvider';
@@ -107,7 +108,9 @@ export function useEntityTypeFilter(): EntityTypeReturn {
const stillValidTypes = selectedTypes.filter(value =>
newTypes.includes(value),
);
setSelectedTypes(stillValidTypes);
if (!isEqual(selectedTypes, stillValidTypes)) {
setSelectedTypes(stillValidTypes);
}
}, [loading, kind, selectedTypes, setSelectedTypes, entities]);
useEffect(() => {