diff --git a/packages/docs-app/src/examples/select-examples/multiSelectExample.tsx b/packages/docs-app/src/examples/select-examples/multiSelectExample.tsx index ff5d0129c2..5006a5ac08 100644 --- a/packages/docs-app/src/examples/select-examples/multiSelectExample.tsx +++ b/packages/docs-app/src/examples/select-examples/multiSelectExample.tsx @@ -40,13 +40,13 @@ const INTENTS = [Intent.NONE, Intent.PRIMARY, Intent.SUCCESS, Intent.DANGER, Int export interface MultiSelectExampleState { allowCreate: boolean; - createdItems: Film[]; + createdItems: readonly Film[]; disabled: boolean; fill: boolean; - films: Film[]; + films: readonly Film[]; hasInitialContent: boolean; intent: boolean; - items: Film[]; + items: readonly Film[]; matchTargetWidth: boolean; openOnKeyDown: boolean; popoverMinimal: boolean; @@ -124,7 +124,7 @@ export class MultiSelectExample extends React.PureComponent - + ; + private renderCustomTarget = (selectedItems: readonly Film[]) => ( + + ); private renderTag = (film: Film) => film.title; @@ -287,11 +289,11 @@ export class MultiSelectExample extends React.PureComponent { - let nextCreatedItems = createdItems.slice(); - let nextFilms = films.slice(); - let nextItems = items.slice(); + let nextCreatedItems = createdItems; + let nextFilms = films; + let nextItems = items; filmsToSelect.forEach(film => { const results = maybeAddCreatedFilmToArrays(nextItems, nextCreatedItems, film); @@ -336,7 +338,7 @@ export class MultiSelectExample extends React.PureComponent { + private handleFilmsPaste = (films: readonly Film[]) => { // On paste, don't bother with deselecting already selected values, just // add the new ones. this.selectFilms(films); diff --git a/packages/docs-app/src/examples/select-examples/omnibarExample.tsx b/packages/docs-app/src/examples/select-examples/omnibarExample.tsx index 19d4596ef0..b30c197123 100644 --- a/packages/docs-app/src/examples/select-examples/omnibarExample.tsx +++ b/packages/docs-app/src/examples/select-examples/omnibarExample.tsx @@ -92,7 +92,7 @@ export class OmnibarExample extends React.PureComponent - + { + private getGroupedItems = (filteredItems: readonly Film[]) => { return filteredItems.reduce>( (acc, item, index) => { const group = this.getGroup(item); @@ -193,7 +193,7 @@ export class SelectExample extends React.PureComponent { + private groupedItemListPredicate = (query: string, items: readonly Film[]) => { return items .filter((item, index) => filterFilm(query, item, index)) .sort((a, b) => this.getGroup(a).localeCompare(this.getGroup(b))); @@ -208,7 +208,7 @@ export class SelectExample extends React.PureComponent this.state.disableItems && film.year < 2000; - private renderGroupedItemList = (listProps: ItemListRendererProps) => { + private renderGroupedItemList = (listProps: ItemListRendererProps) => { const initialContent = this.getInitialContent(); const noResults = ; @@ -231,7 +231,7 @@ export class SelectExample extends React.PureComponent, + listProps: ItemListRendererProps, noResults?: React.ReactNode, initialContent?: React.ReactNode | null, ) => { diff --git a/packages/docs-app/src/examples/select-examples/suggestExample.tsx b/packages/docs-app/src/examples/select-examples/suggestExample.tsx index 835ae1411a..4e6d3941ad 100644 --- a/packages/docs-app/src/examples/select-examples/suggestExample.tsx +++ b/packages/docs-app/src/examples/select-examples/suggestExample.tsx @@ -34,10 +34,10 @@ import { export interface SuggestExampleState { allowCreate: boolean; closeOnSelect: boolean; - createdItems: Film[]; + createdItems: readonly Film[]; disabled: boolean; fill: boolean; - items: Film[]; + items: readonly Film[]; matchTargetWidth: boolean; minimal: boolean; openOnKeyDown: boolean; @@ -92,7 +92,7 @@ export class SuggestExample extends React.PureComponent - + , + SelectProps, | "createNewItemFromQuery" | "createNewItemRenderer" | "itemPredicate" @@ -49,8 +49,8 @@ type FilmSelectProps = Omit< }; export function FilmSelect({ allowCreate = false, fill, ...restProps }: FilmSelectProps) { - const [items, setItems] = React.useState([...TOP_100_FILMS]); - const [createdItems, setCreatedItems] = React.useState([]); + const [items, setItems] = React.useState([...TOP_100_FILMS]); + const [createdItems, setCreatedItems] = React.useState([]); const [selectedFilm, setSelectedFilm] = React.useState(undefined); const handleItemSelect = React.useCallback( (newFilm: Film) => { @@ -82,7 +82,7 @@ export function FilmSelect({ allowCreate = false, fill, ...restProps }: FilmSele ); return ( - + ", () => { testsContainerElement?.remove(); }); - selectComponentSuite, SelectState>(props => + selectComponentSuite, SelectState>(props => mount(", () => { assert.isTrue(wrapper.find(Popover).prop("isOpen")); }); - function select(props: Partial> = {}, query?: string) { + function select(props: Partial> = {}, query?: string) { const wrapper = mount( - {...defaultProps} {...handlers} {...props}> + , { attachTo: testsContainerElement }, diff --git a/packages/select/test/suggestTests.tsx b/packages/select/test/suggestTests.tsx index 2002c8dc29..64d58e3c23 100644 --- a/packages/select/test/suggestTests.tsx +++ b/packages/select/test/suggestTests.tsx @@ -57,7 +57,7 @@ describe("Suggest", () => { testsContainerElement?.remove(); }); - selectComponentSuite, SuggestState>(props => + selectComponentSuite, SuggestState>(props => mount( { }); }); - function suggest(props: Partial> = {}) { - return mount>( {...defaultProps} {...handlers} {...props} />, { + function suggest(props: Partial> = {}) { + return mount>(, { attachTo: testsContainerElement, }); }