From 2231349c302a089cc556614ff562b02a729b1e77 Mon Sep 17 00:00:00 2001 From: Marco Moretti Date: Fri, 24 Apr 2020 10:36:41 +0200 Subject: [PATCH] [Autocomplete] Remove startAfter props (#20729) --- .../components/autocomplete/autocomplete.md | 1 - .../src/useAutocomplete/useAutocomplete.d.ts | 1 - .../src/useAutocomplete/useAutocomplete.js | 5 ---- .../useAutocomplete/useAutocomplete.test.js | 28 ------------------- 4 files changed, 35 deletions(-) diff --git a/docs/src/pages/components/autocomplete/autocomplete.md b/docs/src/pages/components/autocomplete/autocomplete.md index fed08b4f67f927..d3c3e81eaa4247 100644 --- a/docs/src/pages/components/autocomplete/autocomplete.md +++ b/docs/src/pages/components/autocomplete/autocomplete.md @@ -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. diff --git a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.d.ts b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.d.ts index 4d6132cdbf1f1e..2c33f552ccce42 100644 --- a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.d.ts +++ b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.d.ts @@ -5,7 +5,6 @@ export interface CreateFilterOptionsConfig { ignoreCase?: boolean; limit?: number; matchFrom?: 'any' | 'start'; - startAfter?: number; stringify?: (option: T) => string; trim?: boolean; } diff --git a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js index f53b23e23b8d4c..76a1fb32dc2a60 100644 --- a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js +++ b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js @@ -21,7 +21,6 @@ export function createFilterOptions(config = {}) { ignoreCase = true, limit, matchFrom = 'any', - startAfter = 0, stringify, trim = false, } = config; @@ -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) { diff --git a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.test.js b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.test.js index 3c973a8e7260da..10946c31545010 100644 --- a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.test.js +++ b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.test.js @@ -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 });