Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AutocompleteInput only display the first 1000 choices #7884

Closed
wants to merge 7 commits into from

Conversation

antoinefricker
Copy link
Contributor

@antoinefricker antoinefricker commented Jun 23, 2022

Fixes #7880

  • Create story
  • Add test

@antoinefricker antoinefricker added the WIP Work In Progress label Jun 23, 2022
@vercel vercel bot temporarily deployed to Preview – react-admin June 23, 2022 14:39 Inactive
Copy link
Member

@fzaninotto fzaninotto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test would be welcome

@vercel vercel bot temporarily deployed to Preview – react-admin June 23, 2022 23:16 Inactive
@antoinefricker antoinefricker added RFR Ready For Review and removed WIP Work In Progress labels Jun 23, 2022
@antoinefricker antoinefricker removed the RFR Ready For Review label Jun 23, 2022
@@ -160,6 +160,25 @@ export const useList = <RecordType extends RaRecord = any>(
Object.entries(filterValues).every(
([filterName, filterValue]) => {
const recordValue = get(record, filterName);

if (!recordValue) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're testing the value regardless of the filter name. I don't understand what you're doing here. Can you please add a comment to clarify it?

@@ -935,4 +938,35 @@ describe('<AutocompleteInput />', () => {
screen.getByText('No options');
});
});

it('should not display "Dalmatian #1001" when given no `perPage` parameters and a list of 1001 dalmatians', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('should not display "Dalmatian #1001" when given no `perPage` parameters and a list of 1001 dalmatians', async () => {
it('should limit the number of options to the value of the perPage prop', async () => {

expect(screen.queryByText('Dalmatian #1001')).toBeNull();
});

it('should display "Dalmatian #1001" when given `perPage=1001` parameters and a list of 1001 dalmatians', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the test description, speak about the feature you're testing, not the dataset you're using

mutationMode="pessimistic"
mutationOptions={{
onSuccess: data => {
console.log(data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.log spotted

);
};

export const VeryLargeOptionsNumber = (props: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name that Story PerPage, because that's what it demonstrates


export const VeryLargeOptionsNumber = (props: {
perPage?: number;
includeAdmin?: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused

@@ -276,11 +278,6 @@ If you provided a React element for the optionText prop, you must also provide t
if (setFilter) {
return setFilter(filter);
}

if (choicesProp) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you remove that?

@fzaninotto
Copy link
Member

Superseded by #7889

@fzaninotto fzaninotto closed this Jun 24, 2022
@fzaninotto fzaninotto deleted the 7880-AutocompleteInput-options-limit branch August 9, 2023 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

React-Admin AutocompleteInput only uses first 1000 choices
2 participants