Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Persistent Results #705

Merged
merged 2 commits into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GooglePlacesAutocomplete.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ interface GooglePlacesAutocompleteProps {
listEmptyComponent?: JSX.Element | React.ComponentType<{}>;
listUnderlayColor?: string;
listViewDisplayed?: 'auto' | boolean;
keepResultsAfterBlur?: boolean;
minLength?: number; // minimum length of text to search
// Which API to use: GoogleReverseGeocoding or GooglePlacesSearch
nearbyPlacesAPI?: 'GoogleReverseGeocoding' | 'GooglePlacesSearch';
Expand Down
6 changes: 5 additions & 1 deletion GooglePlacesAutocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,9 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => {
const _onBlur = (e) => {
if (e && isNewFocusInAutocompleteResultList(e)) return;

setListViewDisplayed(false);
if (!props.keepResultsAfterBlur) {
setListViewDisplayed(false);
}
inputRef?.current?.blur();
};

Expand Down Expand Up @@ -846,6 +848,7 @@ GooglePlacesAutocomplete.propTypes = {
listEmptyComponent: PropTypes.func,
listUnderlayColor: PropTypes.string,
listViewDisplayed: PropTypes.oneOf(['auto', PropTypes.bool]),
keepResultsAfterBlur: PropTypes.bool,
minLength: PropTypes.number,
nearbyPlacesAPI: PropTypes.string,
numberOfLines: PropTypes.number,
Expand Down Expand Up @@ -894,6 +897,7 @@ GooglePlacesAutocomplete.defaultProps = {
keyboardShouldPersistTaps: 'always',
listUnderlayColor: '#c8c7cc',
listViewDisplayed: 'auto',
keepResultsAfterBlur: false,
minLength: 0,
nearbyPlacesAPI: 'GooglePlacesSearch',
numberOfLines: 1,
Expand Down