Skip to content

Commit

Permalink
[Autocomplete] Remove startAfter props
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosvega91 committed Apr 24, 2020
1 parent ed84f5f commit 4657aa4
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 34 deletions.
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

0 comments on commit 4657aa4

Please sign in to comment.