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

Revert remove hint #8232

Merged
merged 8 commits into from
Mar 28, 2022
Merged

Revert remove hint #8232

merged 8 commits into from
Mar 28, 2022

Conversation

rushatgabhane
Copy link
Member

@rushatgabhane rushatgabhane commented Mar 19, 2022

Details

In PR #8145, hint feature was removed by mistake.
This PR adds back the hint feature.

Thanks to @parasharrajat for pointing this out here - #8044 (comment)

Fixed Issues

$ #8044

Tests

Test 1

  1. npm run storybook
  2. Go to TextInput -> Hint and error input
  3. Verify that you see the hint - "Type Oops! to see the error" in grey color below the input.
  4. Type Oops! in the input.
  5. Verify that you see an error in red - "Oops! Looks like there's an error" below the input.
  6. Erase Oops! from the input.
  7. Verify that you see the hint "Oops! to see the error" again.

Test 2
Currently, we don't use hint prop of TextInput anywhere.
So the following steps are a workaround to test this PR.

  1. Open /src/pages/settings/Payments/AddDebitCardPage.js
  2. Add hint prop to any text input
<TextInput 
     hint="This is a hint"
  1. Go to Settings -> Payments -> Add payment method -> Debit Card
  2. Verify that a hint appears below the text input.
  3. Click submit button.
  4. Verify that the hint is replaced by an error message (if any)
  5. Type something in the text input which has a hint.
  6. Verify that the error is replaced by the hint.
  • Verify that no errors appear in the JS console

PR Review Checklist

Contributor (PR Author) Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors (if there’s a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. “toggleReport” and not “onIconClick”)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct english, and explained “why” the code was doing something instead of only explaining “what” the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct english and approved by marketing by tagging the marketing team on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named “index.js”. All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY
  • I verified any variables that can be defined as constants (ie. in CONST.js) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • Any functional components have the displayName property
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • Any internal methods are bound to “this” properly so there are no scoping issues
    • Any internal methods bound to “this” are necessary to be bound
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose and it is
  • If a new CSS style is added I verified that:
    • A similar style doesn’t already exist
    • The style can’t be created with an existing StyleUtils function
      (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)

PR Reviewer Checklist

  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors (if there’s a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. “toggleReport” and not “onIconClick”).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct english, and explained “why” the code was doing something instead of only explaining “what” the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct english and approved by marketing by tagging the marketing team on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named “index.js”. All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components are not impacted by changes in this PR (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY
  • I verified any variables that can be defined as constants (ie. in CONST.js) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • Any functional components have the displayName property
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • Any internal methods are bound to “this” properly so there are no scoping issues
    • Any internal methods bound to “this” are necessary to be bound
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn’t already exist
    • The style can’t be created with an existing StyleUtils function
      (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)

QA Steps

  1. Go to https://staging.new.expensify.com/docs/index.html?path=/story/components-textinput--hint-and-error-input
  2. Verify that you see the hint - "Type Oops! to see the error" in grey color below the input.
  3. Type Oops! in the input.
  4. Verify that you see an error in red - "Oops! Looks like there's an error" below the input.
  5. Erase Oops! from the input.
  6. Verify that you see the hint "Oops! to see the error" again.
  • Verify that no errors appear in the JS console

Screenshots

Web

Screen.Recording.2022-03-19.at.3.02.05.AM.mov

Mobile Web

Screen.Recording.2022-03-19.at.2.30.08.AM.mov

Desktop

Screen.Recording.2022-03-19.at.2.17.58.AM.mov

iOS

Screen.Recording.2022-03-19.at.2.27.53.AM.mov

Android

screen-20220319-024324.mp4

@rushatgabhane rushatgabhane requested a review from a team as a code owner March 19, 2022 00:03
@rushatgabhane rushatgabhane marked this pull request as draft March 19, 2022 00:05
@rushatgabhane rushatgabhane marked this pull request as ready for review March 19, 2022 00:06
@botify botify requested a review from mountiny March 19, 2022 00:06
@rushatgabhane
Copy link
Member Author

@mountiny I'm sorry for approving the regression. I hope this fixes it.
Thank you so much for your time

@parasharrajat
Copy link
Member

parasharrajat commented Mar 19, 2022

@rushatgabhane I think this should be QA'ed.

@rushatgabhane
Copy link
Member Author

@parasharrajat hint isn't being used anywhere so I'm not sure if QA is possible.
Storybook isn't working either

Co-authored-by: Rajat Parashar <parasharrajat@users.noreply.github.com>
@parasharrajat
Copy link
Member

Storybook isn't working either

Yeah. Hopefully, the fix is not far away. Let's add QA steps to test it in the storybook and we can wait for the storybook to be fixed. How does that sound? This way QA will come to know about this feature.

@AndrewGable AndrewGable requested review from a team and removed request for a team March 21, 2022 22:23
@melvin-bot melvin-bot bot requested review from neil-marcellini and removed request for a team March 21, 2022 22:24
@rushatgabhane
Copy link
Member Author

Sure, sounds good. I'll add the QA steps once the storybook bug is fixed

Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rushatgabhane Thanks for fixing this!

Can you please link where the Storybook bug is being worked on?

@rushatgabhane
Copy link
Member Author

Storybook bug - #8179 (no PR for it yet)

Copy link
Contributor

@neil-marcellini neil-marcellini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me once the storybook QA is added. It looks like the PR has been merged now.

@mountiny mountiny self-requested a review March 22, 2022 22:58
Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rushatgabhane The Storybook fix has been merged #8265 🎉 feel free to update the steps 🙌 thanks!

@rushatgabhane rushatgabhane changed the title [No QA] Revert remove hint Revert remove hint Mar 22, 2022
@rushatgabhane
Copy link
Member Author

rushatgabhane commented Mar 22, 2022

wohoo! QA steps and tests have been updated.

@rushatgabhane rushatgabhane requested a review from mountiny March 22, 2022 23:23
Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! @parasharrajat any thoughts here?

Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. As we are not showing the counter anymore, you should move the value prop from state to class property.

@rushatgabhane
Copy link
Member Author

rushatgabhane commented Mar 24, 2022

As we are not showing the counter anymore, you should move the value prop from state to class property.

@parasharrajat I pushed code which moves value to a class variable.

But are we sure that we wanna do this? The way we've designed autoGrow, text input won't grow if value isn't passed as a prop.

Because we're returning early in componentDidUpdate() when value isn't passed as a prop. So no re-renders will happen.
Please correct me if I'm wrong

componentDidUpdate() {
// Activate or deactivate the label when value is changed programmatically from outside
// Only update when value prop is provided
if (this.props.value === undefined || this.state.value === this.props.value) {
return;

Screen.Recording.2022-03-24.at.9.11.40.AM.mov

@rushatgabhane
Copy link
Member Author

rushatgabhane commented Mar 24, 2022

#8232 (comment)

cc: @sig5 does moving value from state to a class variable help with your PR for modifying IOUAmount?
Is this why you're having trouble merging main into your branch?

@parasharrajat
Copy link
Member

Oh, ok. May be directly update the width for autoGrow without depending on componentDidUpdate

@@ -127,13 +124,13 @@ class BaseTextInput extends Component {
if (this.props.onInputChange) {
this.props.onInputChange(value);
}
this.setState({value});
this.value = value;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be directly update the width for autoGrow without depending on componentDidUpdate

We always have the correct value which is set by callback for onChangeText().

cont below..

@@ -301,7 +302,7 @@ class BaseTextInput extends Component {
style={[...this.props.inputStyle, styles.hiddenElementOutsideOfWindow, styles.visibilityHidden]}
onLayout={e => this.setState({textInputWidth: e.nativeEvent.layout.width})}
>
{this.state.value || this.props.placeholder}
{this.value || this.props.placeholder}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the updated value isn't reflected when calculating the width, because no re-renders happen on typing something in the input (which is a good thing).

This can only be solved by converting value to a state of the component.

@parasharrajat
Copy link
Member

parasharrajat commented Mar 24, 2022

Ok. I see. Yup, I am fine with value in the state. You can revert those commits.

@@ -30,7 +29,6 @@ class BaseTextInput extends Component {
passwordHidden: props.secureTextEntry,
textInputWidth: 0,
prefixWidth: 0,
value,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment here that says keep value in state for the AutoGrow feature to work.

@sig5
Copy link
Contributor

sig5 commented Mar 25, 2022

cc: @sig5 does moving value from state to a class variable help with your #7433?
Is this why you're having trouble merging main into your branch?

I checked again, it seems to work fine for me both ways.

@rushatgabhane
Copy link
Member Author

rushatgabhane commented Mar 25, 2022

I checked again, it seems to work fine for me both ways.

Thanks @sig5, we're safe to move value back to state now.

Commits reverted, and ready for review!

@rushatgabhane rushatgabhane requested a review from mountiny March 25, 2022 14:02
Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not tested. but LGTM.

Copy link
Contributor

@neil-marcellini neil-marcellini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good and the storybook tests work well.

Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this follow-up @rushatgabhane and thanks for the review @parasharrajat and @neil-marcellini Going to merge now 🎉

@mountiny mountiny merged commit e392f2c into Expensify:main Mar 28, 2022
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @mountiny in version: 1.1.47-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Apr 5, 2022

🚀 Deployed to production by @roryabraham in version: 1.1.49-1 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants