Skip to content

Commit

Permalink
fix(components): autocomplete - show options on press
Browse files Browse the repository at this point in the history
  • Loading branch information
artyorsh authored Apr 10, 2020
1 parent ff7b5a5 commit e6e2325
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/components/ui/autocomplete/autocomplete.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import React from 'react';
import {
ListRenderItemInfo,
StyleSheet,
NativeSyntheticEvent,
TextInputSubmitEditingEventData,
View,
} from 'react-native';
import {
Expand Down Expand Up @@ -151,8 +153,17 @@ export class Autocomplete<O extends Option = Option> extends React.Component<Aut
}
};

private onInputSubmitEditing = (e: NativeSyntheticEvent<TextInputSubmitEditingEventData>): void => {
this.setState({ optionsVisible: false });

if (this.props.onSubmitEditing) {
this.props.onSubmitEditing(e);
}
};

private onBackdropPress = (): void => {
this.setState({ optionsVisible: false });
this.inputRef.current.blur();
};

private onOptionPress = (index: number): void => {
Expand Down Expand Up @@ -197,6 +208,7 @@ export class Autocomplete<O extends Option = Option> extends React.Component<Aut
ref={this.inputRef}
{...props}
onFocus={this.onInputFocus}
onSubmitEditing={this.onInputSubmitEditing}
/>
);
};
Expand Down

0 comments on commit e6e2325

Please sign in to comment.