Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const Pagination = forwardRef<HTMLDivElement, PaginationProps>(
const lastPosition = Math.min(page * size, total)

return { firstPosition, lastPosition }
}, [page, total])
}, [page, total, size])

const isSinglePage = total <= size
const paginationLabel = isSinglePage
Expand Down
6 changes: 5 additions & 1 deletion packages/utils/src/flatten-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ export function flattenObject<T extends AnyObject>(
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) {
Expand Down
16 changes: 16 additions & 0 deletions packages/utils/src/tests/flatten-object.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Loading