Enhancement/11889 server pagination#12242
Conversation
|
Storybook is ready:
|
|
Build files for 5da33fd have been deleted. |
|
Size Change: +367 B (+0.02%) Total Size: 2.3 MB ℹ️ View Unchanged
|
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import { useDebounce } from '@/js/hooks/useDebounce'; |
There was a problem hiding this comment.
Debounce and usage are not needed here, as it is handled in parent component
| onInviteResult, | ||
| isLoading = false, | ||
| } ) { | ||
| const filteredUsers = useMemo( () => { |
There was a problem hiding this comment.
Filtering is handled server side now
| expect( getByText( 'AuthorUser' ) ).toBeInTheDocument(); | ||
| } ); | ||
|
|
||
| it( 'filters users by name match', () => { |
There was a problem hiding this comment.
Filter related tests are redundant now, as filtering is handled server side
| useEffect( () => { | ||
| setInputValue( value ); | ||
| }, [ value ] ); |
There was a problem hiding this comment.
No longer needed, because the component is fully controlled (value comes directly from parent, no local inputValue state).
tofumatt
left a comment
There was a problem hiding this comment.
I think we can simplify the selector handling and add another test for it here, but otherwise looks good 👍🏻
| // Reuse the current selector result when search is empty to avoid duplicate requests. | ||
| if ( debouncedSearchTerm === '' ) { | ||
| return undefined; | ||
| } |
There was a problem hiding this comment.
This says it's re-using a selector result, but it's just returning undefined here. 🤔
Shouldn't we always be returning the eligible subscribers from below? 🤔
| if ( ! hasOpenedSelectionPanel ) { | ||
| return undefined; | ||
| } |
There was a problem hiding this comment.
Same here re: undefined vs null.
| const eligibleSubscribersForSearchThreshold = | ||
| debouncedSearchTerm === '' | ||
| ? eligibleSubscribers | ||
| : allEligibleSubscribers; |
There was a problem hiding this comment.
If debouncedSearchTerm === '' then the same selector will be used twice and shouldn't actually trigger another request while it's resolving.
I think you can remove the logic here that tries to be "clever" about not using the same selector in multiple places and let WP Data handle it—I think it should prevent duplicate requests 🤔
assets/js/components/email-reporting/InviteOthersToSubscribe/index.test.js
Show resolved
Hide resolved
tofumatt
left a comment
There was a problem hiding this comment.
Awesome, looks great, thanks for adding that test 👍🏻
tofumatt
left a comment
There was a problem hiding this comment.
Looks like there's a few merge conflicts to resolve, but after that this is good-to-go 👍🏻
|
Thanks, conflicts resolved |
Summary
Addresses issue:
Relevant technical choices
PR Author Checklist
Do not alter or remove anything below. The following sections will be managed by moderators only.
Code Reviewer Checklist
Merge Reviewer Checklist