From 496f3857c0d1073d01693015a3811be07e9b1fbb Mon Sep 17 00:00:00 2001 From: uzairr Date: Fri, 11 Jun 2021 16:25:06 +0500 Subject: [PATCH] fix issues in typeahead --- src/register/CountryDropdown.jsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/register/CountryDropdown.jsx b/src/register/CountryDropdown.jsx index b1898a6d..2675a39b 100644 --- a/src/register/CountryDropdown.jsx +++ b/src/register/CountryDropdown.jsx @@ -21,7 +21,7 @@ class CountryDropdown extends React.Component { } shouldComponentUpdate(nextProps) { - if (this.props.value !== nextProps.value) { + if (this.props.value !== nextProps.value && nextProps.value !== null) { const opt = this.props.options.find((o) => o[this.props.valueKey] === nextProps.value); if (opt && opt[this.props.displayValueKey] !== this.state.displayValue) { this.setState({ displayValue: opt[this.props.displayValueKey], showFieldError: false }); @@ -87,13 +87,16 @@ class CountryDropdown extends React.Component { } } - handleClick = () => { + handleClick = (e) => { if (!this.props.value) { - const dropDownItems = this.getItems(); + const dropDownItems = this.getItems(e.target.value); this.setState({ dropDownItems, icon: ExpandLess, errorMessage: '', showFieldError: false, }); } + if (this.state.dropDownItems?.length > 0) { + this.setState({ dropDownItems: '', icon: ExpandMore }); + } } handleOnChange = (e) => {