From f694dc502d371e9f0b7794b477ef171dc494be4e Mon Sep 17 00:00:00 2001 From: Katsuki <1313124+K4tsuki@users.noreply.github.com> Date: Fri, 4 Feb 2022 10:40:04 +0700 Subject: [PATCH 1/6] clear search group after select a user --- src/components/TextInput/BaseTextInput.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/TextInput/BaseTextInput.js b/src/components/TextInput/BaseTextInput.js index c4a2693b5d44..d6b7cbd904cc 100644 --- a/src/components/TextInput/BaseTextInput.js +++ b/src/components/TextInput/BaseTextInput.js @@ -53,6 +53,9 @@ class BaseTextInput extends Component { } this.value = this.props.value; + if (this.props.value === '') { + this.input.clear(); + } if (this.props.value) { this.activateLabel(); From 66867f289f4ee83791efb36a28ba10c83ac4fe97 Mon Sep 17 00:00:00 2001 From: Katsuki <1313124+K4tsuki@users.noreply.github.com> Date: Fri, 4 Feb 2022 22:22:34 +0700 Subject: [PATCH 2/6] Add comment --- src/components/TextInput/BaseTextInput.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/TextInput/BaseTextInput.js b/src/components/TextInput/BaseTextInput.js index d6b7cbd904cc..1bb3ae61e5f5 100644 --- a/src/components/TextInput/BaseTextInput.js +++ b/src/components/TextInput/BaseTextInput.js @@ -52,6 +52,10 @@ class BaseTextInput extends Component { return; } + // Since BaseTextInput value is depend on this.value + // Providing value to BaseTextInput via props.value will be late one step behind + // So at componentDidUpdate we update the real value of TextInput + // If this.props.value is empty string, we must clear the TextInput this.value = this.props.value; if (this.props.value === '') { this.input.clear(); From 3c035d632abbad273c736435978cdce640a10cb9 Mon Sep 17 00:00:00 2001 From: Katsuki <1313124+K4tsuki@users.noreply.github.com> Date: Fri, 4 Feb 2022 22:25:45 +0700 Subject: [PATCH 3/6] Placement comment --- src/components/TextInput/BaseTextInput.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/TextInput/BaseTextInput.js b/src/components/TextInput/BaseTextInput.js index 1bb3ae61e5f5..5b897768e593 100644 --- a/src/components/TextInput/BaseTextInput.js +++ b/src/components/TextInput/BaseTextInput.js @@ -52,11 +52,12 @@ class BaseTextInput extends Component { return; } + this.value = this.props.value; + // Since BaseTextInput value is depend on this.value // Providing value to BaseTextInput via props.value will be late one step behind // So at componentDidUpdate we update the real value of TextInput // If this.props.value is empty string, we must clear the TextInput - this.value = this.props.value; if (this.props.value === '') { this.input.clear(); } From d7cb027319c455565bc53ecc309183cd7f96ff69 Mon Sep 17 00:00:00 2001 From: Katsuki <1313124+K4tsuki@users.noreply.github.com> Date: Fri, 4 Feb 2022 22:32:54 +0700 Subject: [PATCH 4/6] Fix lint error --- src/components/TextInput/BaseTextInput.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TextInput/BaseTextInput.js b/src/components/TextInput/BaseTextInput.js index 5b897768e593..819843993113 100644 --- a/src/components/TextInput/BaseTextInput.js +++ b/src/components/TextInput/BaseTextInput.js @@ -56,7 +56,7 @@ class BaseTextInput extends Component { // Since BaseTextInput value is depend on this.value // Providing value to BaseTextInput via props.value will be late one step behind - // So at componentDidUpdate we update the real value of TextInput + // So at componentDidUpdate we update the real value of TextInput // If this.props.value is empty string, we must clear the TextInput if (this.props.value === '') { this.input.clear(); From cbd168fc7e246dad7820d033ce761159c73e07d3 Mon Sep 17 00:00:00 2001 From: Rocio Perez Date: Fri, 4 Feb 2022 13:35:22 -0500 Subject: [PATCH 5/6] Update src/components/TextInput/BaseTextInput.js Co-authored-by: Rajat Parashar --- src/components/TextInput/BaseTextInput.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/TextInput/BaseTextInput.js b/src/components/TextInput/BaseTextInput.js index 819843993113..05d3fce17768 100644 --- a/src/components/TextInput/BaseTextInput.js +++ b/src/components/TextInput/BaseTextInput.js @@ -54,10 +54,7 @@ class BaseTextInput extends Component { this.value = this.props.value; - // Since BaseTextInput value is depend on this.value - // Providing value to BaseTextInput via props.value will be late one step behind - // So at componentDidUpdate we update the real value of TextInput - // If this.props.value is empty string, we must clear the TextInput + // In some cases, When the value prop is empty, it is not properly updated on the TextInput due to its uncontrolled nature, thus manually clearing the TextInput. if (this.props.value === '') { this.input.clear(); } From 654b8a8e5db2bece812cc62bc1c3fb70276ee349 Mon Sep 17 00:00:00 2001 From: Katsuki <1313124+K4tsuki@users.noreply.github.com> Date: Sat, 5 Feb 2022 12:54:09 +0700 Subject: [PATCH 6/6] Fix lint error 2 --- src/components/TextInput/BaseTextInput.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TextInput/BaseTextInput.js b/src/components/TextInput/BaseTextInput.js index 05d3fce17768..4c03bb620615 100644 --- a/src/components/TextInput/BaseTextInput.js +++ b/src/components/TextInput/BaseTextInput.js @@ -54,7 +54,7 @@ class BaseTextInput extends Component { this.value = this.props.value; - // In some cases, When the value prop is empty, it is not properly updated on the TextInput due to its uncontrolled nature, thus manually clearing the TextInput. + // In some cases, When the value prop is empty, it is not properly updated on the TextInput due to its uncontrolled nature, thus manually clearing the TextInput. if (this.props.value === '') { this.input.clear(); }