Skip to content

Commit a3ef5ee

Browse files
authored
fix(ui): reset pagination when typing in WhereBuilder select menu (#10551)
After working on this I found a more accurate way to reproduce the bug: - in the issue repro, type a letter in the select menu. - delete the letter and wait for the debounce (300ms) - type another letter. - in devtools, you should see that the query increases the pagination by +1. With this change, the pagination is reset when the input changes. Fixes #10496 I'd like to do integration testing. But since there is no isolated `/ui` test yet, this requires some planning. I have it pending.
1 parent f95d6ba commit a3ef5ee

File tree

1 file changed

+5
-8
lines changed
  • packages/ui/src/elements/WhereBuilder/Condition/Relationship

1 file changed

+5
-8
lines changed

packages/ui/src/elements/WhereBuilder/Condition/Relationship/index.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,11 @@ export const RelationshipField: React.FC<Props> = (props) => {
208208
return undefined
209209
}, [hasMany, hasMultipleRelations, value, options])
210210

211-
const handleInputChange = useCallback(
212-
(newSearch) => {
213-
if (search !== newSearch) {
214-
setSearch(newSearch)
215-
}
216-
},
217-
[search],
218-
)
211+
const handleInputChange = (input: string) => {
212+
const relationSlug = partiallyLoadedRelationshipSlugs.current[0]
213+
nextPageByRelationshipRef.current.set(relationSlug, 1)
214+
setSearch(input)
215+
}
219216

220217
const addOptionByID = useCallback(
221218
async (id, relation) => {

0 commit comments

Comments
 (0)