From a258dc92515835de1f01a6e9e2f7ec1b34ebfa7a Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Tue, 19 Feb 2019 00:57:38 +0100 Subject: [PATCH 1/3] Make the test more realistic --- .../react-places-autocomplete-tests.tsx | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/types/react-places-autocomplete/react-places-autocomplete-tests.tsx b/types/react-places-autocomplete/react-places-autocomplete-tests.tsx index 7d72ac4397..3da7a4e81c 100644 --- a/types/react-places-autocomplete/react-places-autocomplete-tests.tsx +++ b/types/react-places-autocomplete/react-places-autocomplete-tests.tsx @@ -31,18 +31,30 @@ class Test extends React.Component { return (
- {({getInputProps, getSuggestionItemProps, suggestions}) => ( - <> - -
- {suggestions.map(suggestion => ( -
- {suggestion.description} -
- ))} -
- - )} + {({getInputProps, suggestions, getSuggestionItemProps, loading}) => { + const inputProps = getInputProps({ + required: true, + className: loading ? 'is-pending' : '' + }); + return ( + <> + +
+ {suggestions.map(suggestion => { + const divProps = getSuggestionItemProps(suggestion, { + className: suggestion.active ? 'active' : '' + }); + return ( +
+ {suggestion.description} +
+ ); + })} +
+ + ); + } + }
); From 0cf627b0fb947cd91ce0eb29bce8a8b4fd38a4b5 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Tue, 19 Feb 2019 00:59:35 +0100 Subject: [PATCH 2/3] Replace null JSX attributes by undefined See https://github.com/hibiken/react-places-autocomplete/pull/256 See https://codesandbox.io/s/yw7o81nq39 --- types/react-places-autocomplete/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-places-autocomplete/index.d.ts b/types/react-places-autocomplete/index.d.ts index dffcbf29f8..cd299d5bd5 100644 --- a/types/react-places-autocomplete/index.d.ts +++ b/types/react-places-autocomplete/index.d.ts @@ -53,7 +53,7 @@ export interface PropTypes { role: 'combobox'; 'aria-autocomplete': 'list'; 'aria-expanded': boolean; - 'aria-activedescendant': string | null; + 'aria-activedescendant': string | undefined; disabled: boolean; onKeyDown: React.KeyboardEventHandler; onBlur: () => void; @@ -62,7 +62,7 @@ export interface PropTypes { } & InputProps; getSuggestionItemProps: (suggestion: Suggestion, options?: SuggestionProps) => { key: number; - id: string | null; + id: string | undefined; role: 'option'; onMouseEnter: () => void; onMouseLeave: () => void; From c705e8559de1600cf721a41a603ff444b150cfd8 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Tue, 19 Feb 2019 01:00:36 +0100 Subject: [PATCH 3/3] Generalize the use of React.*EventHandler --- types/react-places-autocomplete/index.d.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/types/react-places-autocomplete/index.d.ts b/types/react-places-autocomplete/index.d.ts index cd299d5bd5..bf11a9fa30 100644 --- a/types/react-places-autocomplete/index.d.ts +++ b/types/react-places-autocomplete/index.d.ts @@ -56,7 +56,7 @@ export interface PropTypes { 'aria-activedescendant': string | undefined; disabled: boolean; onKeyDown: React.KeyboardEventHandler; - onBlur: () => void; + onBlur: React.FocusEventHandler; value: string | undefined; onChange: (ev: { target: { value: string }}) => void; } & InputProps; @@ -64,13 +64,13 @@ export interface PropTypes { key: number; id: string | undefined; role: 'option'; - onMouseEnter: () => void; - onMouseLeave: () => void; + onMouseEnter: React.MouseEventHandler; + onMouseLeave: React.MouseEventHandler; onMouseDown: React.MouseEventHandler; - onMouseUp: () => void; - onTouchStart: () => void; - onTouchEnd: () => void; - onClick: (event?: Event) => void; + onMouseUp: React.MouseEventHandler; + onTouchStart: React.TouchEventHandler; + onTouchEnd: React.TouchEventHandler; + onClick: React.MouseEventHandler; } & SuggestionProps; }>) => React.ReactNode; }