You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
When blurring the emoji picker search field, it wobbles if it is not empty #26436
This means that even if the text input is not empty, label deactivation will begin, leading to the buggy animation.
Previously, the value of the input was stored inside of the BaseTextInput component, but there was a conscious decision made to remove that in this PR. Since then the value prop has been used to determine if the label should animate back or not.
What changes do you think we should make in order to solve the problem?
There is already a ref, called hasValueRef inside the BaseTextInput component that keeps track of whether or not the input has a value:
if (props.forceActiveLabel || props.prefixCharacter || hasValueRef.current) {
return;
}
If the input has a value, we do not want the deactivation animation of the label to start. We could likely remove the check of the length of the value prop entirely in that conditional, since checking hasValueRef accomplishes the same thing.
This approach makes the most sense IMO. I think hinging the animation logic on the length of a prop that isn't required is suboptimal when the BaseTextInput component already stores whether or not the text input is empty.
What alternative solutions did you explore? (Optional)
Alternative solution 1
Alternatively we could pass the value prop from the EmojiPickerMenu component to the BaseTextInput component. I do not think this approach is the best one, as the EmojiPickerMenu currently does not actually store the search term. Rather, it is used right away to filter emojis:
If we choose this approach, I think we should consider making the value prop required to make it clear that the BaseTextInput component does not function 100% correctly without it.
Alternative solution 2
Another alternative would be to start storing the current input value in the BaseTextInput component again. I do not really think this is worth considering, given that a decision has been made to not store the current input value in the BaseTextInput component, but it is an option. It is also not really required, since we are only interested in whether or not the input is empty, not the actual value of the input.
Activity
melvin-bot commentedon Aug 31, 2023
Triggered auto assignment to @laurenreidexpensify (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Aug 31, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)kbecciv commentedon Aug 31, 2023
Proposal from @joh42
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1692728174404989
Proposal
Please re-state the problem that we are trying to solve in this issue.
When blurring the emoji picker search field, it wobbles if it is not empty.
What is the root cause of that problem?
The root cause of the issue is that the BaseTextInput component checks the length of the
valueprop before animating the label:App/src/components/TextInput/BaseTextInput.js
Lines 112 to 117 in 44eb88a
But the EmojiPickerMenu does not pass any value prop:
App/src/components/EmojiPicker/EmojiPickerMenu/index.js
Lines 536 to 549 in 44eb88a
This means that even if the text input is not empty, label deactivation will begin, leading to the buggy animation.
Previously, the value of the input was stored inside of the BaseTextInput component, but there was a conscious decision made to remove that in this PR. Since then the
valueprop has been used to determine if the label should animate back or not.What changes do you think we should make in order to solve the problem?
There is already a ref, called
hasValueRefinside the BaseTextInput component that keeps track of whether or not the input has a value:App/src/components/TextInput/BaseTextInput.js
Lines 184 to 186 in 44eb88a
I suggest we check that ref as well in the
deactivateLabelfunction's early return:App/src/components/TextInput/BaseTextInput.js
Lines 112 to 117 in 44eb88a
Which would look something like this:
If the input has a value, we do not want the deactivation animation of the label to start. We could likely remove the check of the length of the value prop entirely in that conditional, since checking
hasValueRefaccomplishes the same thing.This approach makes the most sense IMO. I think hinging the animation logic on the length of a prop that isn't required is suboptimal when the BaseTextInput component already stores whether or not the text input is empty.
What alternative solutions did you explore? (Optional)
Alternative solution 1
Alternatively we could pass the
valueprop from the EmojiPickerMenu component to the BaseTextInput component. I do not think this approach is the best one, as the EmojiPickerMenu currently does not actually store the search term. Rather, it is used right away to filter emojis:App/src/components/EmojiPicker/EmojiPickerMenu/index.js
Line 540 in 44eb88a
App/src/components/EmojiPicker/EmojiPickerMenu/index.js
Lines 419 to 420 in fc9378e
As such we would have to start storing the search term in both the regular EmojiPickerMenu and the native EmojiPickerMenu just so that the BaseTextInput label can animate correctly.
If we choose this approach, I think we should consider making the
valueprop required to make it clear that the BaseTextInput component does not function 100% correctly without it.Alternative solution 2
Another alternative would be to start storing the current input value in the BaseTextInput component again. I do not really think this is worth considering, given that a decision has been made to not store the current input value in the BaseTextInput component, but it is an option. It is also not really required, since we are only interested in whether or not the input is empty, not the actual value of the input.
bernhardoj commentedon Sep 1, 2023
Should be fixed in #26399
laurenreidexpensify commentedon Sep 4, 2023
Closing for #26399