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

[Autocomplete] Remove startAfter props #20729

Merged
merged 2 commits into from
Apr 24, 2020
Merged
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
1 change: 0 additions & 1 deletion docs/src/pages/components/autocomplete/autocomplete.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ import { createFilterOptions } from '@material-ui/lab/Autocomplete';
- `config.ignoreCase` (*Boolean* [optional]): Defaults to `true`. Lowercase everything.
- `config.limit` (*Number* [optional]): Default to null. Limit the number of suggested options to be shown. For example, if `config.limit` is `100`, only the first `100` matching options are shown. It can be useful if a lot of options match and virtualization wasn't set up.
- `config.matchFrom` (*'any' | 'start'* [optional]): Defaults to `'any'`.
- `config.startAfter`(*Number* [optional]): Default to `0`. Show the suggested options only after a certain number of letters
- `config.stringify` (*Func* [optional]): Controls how an option is converted into a string so that it can be matched against the input text fragment.
- `config.trim` (*Boolean* [optional]): Defaults to `false`. Remove trailing spaces.

Comment on lines 166 to 171
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I run the command to build the docs but nothing happens

Copy link
Member

@oliviertassinari oliviertassinari Apr 24, 2020

Choose a reason for hiding this comment

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

These ones are handcrafted 🙃

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah ok 😢

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export interface CreateFilterOptionsConfig<T> {
ignoreCase?: boolean;
limit?: number;
matchFrom?: 'any' | 'start';
startAfter?: number;
stringify?: (option: T) => string;
trim?: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export function createFilterOptions(config = {}) {
ignoreCase = true,
limit,
matchFrom = 'any',
startAfter = 0,
stringify,
trim = false,
} = config;
Expand All @@ -35,10 +34,6 @@ export function createFilterOptions(config = {}) {
input = stripDiacritics(input);
}

if (startAfter > 0 && input.length <= startAfter) {
return [];
}

const filteredOptions = options.filter((option) => {
let candidate = (stringify || getOptionLabel)(option);
if (ignoreCase) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,6 @@ describe('createFilterOptions', () => {
expect(filterOptions(options, { inputValue: 'a', getOptionLabel })).to.deep.equal([options[0]]);
});

describe('option: startAfter', () => {
it('start to search only after the second letter', () => {
const filterOptions = createFilterOptions({ startAfter: 2 });

const getOptionLabel = (option) => option.name;
const options = [
{
id: '1234',
name: 'cat',
},
{
id: '5678',
name: 'dog',
},
{
id: '9abc',
name: 'emu',
},
];

expect(filterOptions(options, { inputValue: 'c', getOptionLabel })).to.deep.equal([]);
expect(filterOptions(options, { inputValue: 'ca', getOptionLabel })).to.deep.equal([]);
expect(filterOptions(options, { inputValue: 'cat', getOptionLabel })).to.deep.equal([
options[0],
]);
});
});

describe('option: limit', () => {
it('limits the number of suggested options to be shown', () => {
const filterOptions = createFilterOptions({ limit: 2 });
Expand Down