From 59a23ff5d98950edf5fd4e5d4fb563e56cdae916 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 21 Dec 2025 14:25:55 +0000 Subject: [PATCH] Fix: Add size to pagination dependency, preserve null in flattenObject Co-authored-by: matheus.procopio --- .../src/components/filter/filter-provider.tsx | 9 ++++++--- .../src/components/pagination/pagination.tsx | 2 +- packages/utils/src/flatten-object.ts | 6 +++++- packages/utils/src/tests/flatten-object.test.ts | 16 ++++++++++++++++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/packages/shoreline/src/components/filter/filter-provider.tsx b/packages/shoreline/src/components/filter/filter-provider.tsx index 53c896a015..0833afb510 100644 --- a/packages/shoreline/src/components/filter/filter-provider.tsx +++ b/packages/shoreline/src/components/filter/filter-provider.tsx @@ -45,9 +45,12 @@ export function FilterProvider(props: FilterProviderProps) { defaultValue, }) - useEffect(function syncState() { - selectStore.setValue(filterStore.getState().value) - }, []) + useEffect( + function syncState() { + selectStore.setValue(filterStore.getState().value) + }, + [selectStore, filterStore] + ) const searchable = !!searchValue || !!setSearchValue || !!defaultSearchValue diff --git a/packages/shoreline/src/components/pagination/pagination.tsx b/packages/shoreline/src/components/pagination/pagination.tsx index 0614660dbe..5f0a0dd325 100644 --- a/packages/shoreline/src/components/pagination/pagination.tsx +++ b/packages/shoreline/src/components/pagination/pagination.tsx @@ -41,7 +41,7 @@ export const Pagination = forwardRef( const lastPosition = Math.min(page * size, total) return { firstPosition, lastPosition } - }, [page, total]) + }, [page, total, size]) const isSinglePage = total <= size const paginationLabel = isSinglePage diff --git a/packages/utils/src/flatten-object.ts b/packages/utils/src/flatten-object.ts index a96521b80a..4bef0e8727 100644 --- a/packages/utils/src/flatten-object.ts +++ b/packages/utils/src/flatten-object.ts @@ -8,7 +8,11 @@ export function flattenObject( const result: Dict = {} for (const i in object) { - if (typeof object[i] === 'object' && !Array.isArray(object[i])) { + if ( + typeof object[i] === 'object' && + object[i] !== null && + !Array.isArray(object[i]) + ) { const temp = flattenObject(object[i], joinString, defaultString) for (const j in temp) { diff --git a/packages/utils/src/tests/flatten-object.test.ts b/packages/utils/src/tests/flatten-object.test.ts index f8aaab9b8c..5b19ca7927 100644 --- a/packages/utils/src/tests/flatten-object.test.ts +++ b/packages/utils/src/tests/flatten-object.test.ts @@ -20,6 +20,22 @@ describe('flattenObject', () => { expect(result).toStrictEqual(expectation) }) + it('should preserve null values', () => { + const result = flattenObject({ + a: { + b: null, + c: 'value', + }, + }) + + const expectation = { + 'a-b': null, + 'a-c': 'value', + } + + expect(result).toStrictEqual(expectation) + }) + it('should handle default values', () => { const result = flattenObject({ a: {