From 0041e8f2d2b057544af9d000b61806186ddbde69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Eikeland?= Date: Mon, 3 Aug 2026 09:07:25 +0200 Subject: [PATCH 1/2] fix(filter): refactor selected count calculation in FilterOptionHeader --- packages/filter/src/components/filter/FilterOptionHeader.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/filter/src/components/filter/FilterOptionHeader.tsx b/packages/filter/src/components/filter/FilterOptionHeader.tsx index 2f7cdafcf..3e9178209 100644 --- a/packages/filter/src/components/filter/FilterOptionHeader.tsx +++ b/packages/filter/src/components/filter/FilterOptionHeader.tsx @@ -14,6 +14,8 @@ type FilterHeaderProps = { readonly title: string; }; +const getSelectedCount = (selection?: Set): number => selection?.size ?? 0; + const Styled = { Root: styled.div` display: flex; @@ -63,7 +65,7 @@ export const FilterOptionHeader = (props: FilterHeaderProps): ReactElement => { const { options$, selection$ } = useFilterOptionContext(); const optionCount = Object.keys(useObservableState(options$).value || {}).length; const { value: selectedCount } = useObservableState( - useObservableSelector(selection$, (x) => (x ?? new Set()).size), + useObservableSelector(selection$, getSelectedCount), { initial: 0 }, ); From 0318e17fab7214731eeaa0bb9f52b3d04e8bbca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Eikeland?= Date: Mon, 3 Aug 2026 09:11:16 +0200 Subject: [PATCH 2/2] fix(filter): prevent infinite render loop in FilterOptionHeader --- .changeset/stable-filter-selector.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/stable-filter-selector.md diff --git a/.changeset/stable-filter-selector.md b/.changeset/stable-filter-selector.md new file mode 100644 index 000000000..274c288f3 --- /dev/null +++ b/.changeset/stable-filter-selector.md @@ -0,0 +1,5 @@ +--- +"@equinor/fusion-react-filter": patch +--- + +Prevent `FilterOptionHeader` from entering an infinite render loop after upgrading `@equinor/fusion-observable` by keeping its selection count selector stable across renders.