Skip to content

Conversation

@luacmartins
Copy link
Contributor

@luacmartins luacmartins commented Jan 27, 2023

Details

Disabled Company name, Tax ID, Routing number and Account number inputs once the user has reached the Personal information step.

Additionally, from this issue, passing something else other than a Boolean to certain props, e.g. disabled, can cause crashes. This PR does not fix the mentioned issue, but it ensures that we pass the correct prop types.

cc @nkuoch

Fixed Issues

$ #14705

Tests

  1. Navigate to Settings > Workspace > Add bank account
  2. Enter 011401533 and 1111222233331111 for routing and account numbers, respectively
  3. Fill in the Company step with random data
  4. Tap Save & continue
  5. Verify that the form submits
  6. On Personal information, tap < to go back to the Company step
  7. Verify that you cannot edit the Company name and Tax ID fields anymore.
  8. Tap < and then Continue with setup
  9. Verify that the Routing number and Account number inputs are disabled
  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

Same as tests

  • Verify that no errors appear in the JS console

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 the expected offline behavior in the Offline steps 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 tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • 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 is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review 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 (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • 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 */
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • 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 any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
web.mov
Mobile Web - Chrome
chrome.mov
Mobile Web - Safari
safari.mov
Desktop
desktop.mov
iOS
ios.mov
Android
android.mov

@luacmartins luacmartins self-assigned this Jan 27, 2023
@luacmartins luacmartins mentioned this pull request Jan 30, 2023
59 tasks
@luacmartins luacmartins marked this pull request as ready for review January 31, 2023 19:19
@luacmartins luacmartins requested a review from a team as a code owner January 31, 2023 19:19
@melvin-bot melvin-bot bot requested review from aimane-chnaif and youssef-lr and removed request for a team January 31, 2023 19:20
@melvin-bot
Copy link

melvin-bot bot commented Jan 31, 2023

@aimane-chnaif @youssef-lr One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@luacmartins luacmartins changed the title Cast shouldDisableCompanyName and shouldDisableCompanyTaxID to bools Disable VBA inputs on native platforms when user reaches Personal information step Jan 31, 2023
@@ -100,6 +100,7 @@ class BankAccountManualStep extends React.Component {
defaultValue={this.props.getDefaultStateForField('routingNumber', '')}
keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD}
disabled={shouldDisableInputs}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd expect disabled to prevent editing .. why do we need both? Can't we make a global fix directly in TextInput?

Copy link
Contributor Author

@luacmartins luacmartins Feb 1, 2023

Choose a reason for hiding this comment

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

I'd expect disabled to prevent editing ..

AFAIK disabled is only a react-native-web prop. react-native itself uses editable and has no disabled prop available on TextInputs.

why do we need both?

disabled is not available in react-native so we can't use it for both browser and native platforms. Although editable is available in both react-native and react-native-web, it's equivalent in react-native-web is HTMLElement.readonly, instead of HTMLElement.disabled. That means that the input can't be changed, but we can still focus / blur which triggers style changes, etc.

Can't we make a global fix directly in TextInput?

We certainly can. I just kept it consistent with these other instances here and here, but we could change those as well. Would that be your preference?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @nkuoch here. What do you think about fixing it here? I just tested it and it seems to work well.

diff --git a/src/components/TextInput/BaseTextInput.js b/src/components/TextInput/BaseTextInput.js
index 87f02ba528..df118a524f 100644
--- a/src/components/TextInput/BaseTextInput.js
+++ b/src/components/TextInput/BaseTextInput.js
@@ -274,6 +274,7 @@ class BaseTextInput extends Component {
                                         }}
                                         // eslint-disable-next-line
                                         {...inputProps}
+                                        editable={!this.props.disabled}
                                         autoCorrect={this.props.secureTextEntry ? false : this.props.autoCorrect}
                                         placeholder={placeholder}
                                         placeholderTextColor={themeColors.placeholderText}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I can fix it in BaseTextInput! We might need a bit more logic than that since there are instances where we want to disable it on mobile, but not necessarily on web e.g. here

Copy link
Contributor

@youssef-lr youssef-lr Feb 2, 2023

Choose a reason for hiding this comment

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

I'm not familiar with platform specific code so far so I'm curious, wouldn't that code only run on Android?

Answering my own question and yes this is correct and it makes sense to check for editable the way you did.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct! We have 3 DatePicker components (web, android and ios) each with its own logic - the code I linked above is from the android component and is run on android only.

@luacmartins
Copy link
Contributor Author

Updated!

Copy link
Contributor

@youssef-lr youssef-lr left a comment

Choose a reason for hiding this comment

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

LGTM and tested well!

@youssef-lr
Copy link
Contributor

youssef-lr commented Feb 2, 2023

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • 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 included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • 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 is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review 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 that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) 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 */
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • 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 any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
web.mov
Mobile Web - Chrome
android.chrome.mov
Mobile Web - Safari
mWeb.safari.MP4
Desktop
desktop.mov
iOS
ios.mov
Android
android.mov

@aimane-chnaif
Copy link
Contributor

I will review shortly

@aimane-chnaif
Copy link
Contributor

Screenshots/Videos

Web
web.mov
Mobile Web - Chrome
mchrome.mov
Mobile Web - Safari
msafari.mp4
Desktop
desktop.mov
iOS
ios.mp4
Android
android.mov

Looks good and tests well!
Just added my test videos since checklist was already filled by @youssef-lr

@aimane-chnaif
Copy link
Contributor

I also agree to fix this in low level (BaseTextInput) for platform consistency.
This approach was already applied in Composer to disable editing on native when isDisabled=true

iOS:

editable={!this.props.isDisabled}

Android:
editable={!this.props.isDisabled}

Web:
disabled={this.props.isDisabled}

@youssef-lr youssef-lr merged commit a638ca2 into main Feb 3, 2023
@youssef-lr youssef-lr deleted the cmartins-castToBool branch February 3, 2023 17:43
@OSBotify
Copy link
Contributor

OSBotify commented Feb 3, 2023

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2023

Performance Comparison Report 📊

Significant Changes To Duration

There are no entries

Meaningless Changes To Duration

Show entries
Name Duration
App start TTI 686.441 ms → 707.156 ms (+20.715 ms, +3.0%)
App start runJsBundle 194.250 ms → 194.903 ms (+0.653 ms, ±0.0%)
App start regularAppStart 0.014 ms → 0.015 ms (+0.000 ms, +3.5%)
App start nativeLaunch 19.581 ms → 19.419 ms (-0.161 ms, -0.8%)
Open Search Page TTI 607.748 ms → 607.547 ms (-0.201 ms, ±0.0%)
Show details
Name Duration
App start TTI Baseline
Mean: 686.441 ms
Stdev: 42.394 ms (6.2%)
Runs: 597.7028200002387 624.2166389999911 625.7106520002708 633.2986070001498 642.9004720002413 643.0061259996146 644.422588000074 655.6115030003712 660.6521180002019 661.8637990001589 665.1481269998476 670.5711930003017 675.8157799998298 675.9687719997019 678.6037029996514 679.8099840003997 681.8055590000004 682.297203999944 682.3275279998779 695.8055769996718 701.1412279997021 712.9300210000947 713.3623240003362 715.496741999872 720.396596999839 724.723497999832 729.3674739999697 743.1055389996618 749.3829199997708 750.248626999557 760.7859169999138 767.6238559996709

Current
Mean: 707.156 ms
Stdev: 32.828 ms (4.6%)
Runs: 665.4995379997417 669.353132000193 670.3648309996352 670.5202559996396 673.6772370003164 678.3272789996117 679.441963000223 683.4717560000718 683.6056960001588 688.4858320001513 689.8816069997847 689.9159180000424 691.3029349995777 691.6689750002697 693.1927829999477 695.6601550001651 696.09606899973 698.7168220002204 701.5145739996806 701.9683119999245 711.2378759998828 711.3649700004607 725.647691000253 730.3713140003383 730.6770200002939 731.2409129999578 740.4607070004568 740.9695859998465 753.1814419999719 767.8343409998342 782.899849999696 790.440523000434
App start runJsBundle Baseline
Mean: 194.250 ms
Stdev: 24.289 ms (12.5%)
Runs: 153 159 165 167 170 170 173 174 176 176 177 184 184 185 190 190 192 193 200 203 205 206 208 208 212 215 215 216 223 225 237 265

Current
Mean: 194.903 ms
Stdev: 13.289 ms (6.8%)
Runs: 172 174 175 177 178 181 182 183 187 189 191 192 192 192 194 195 196 197 197 199 200 201 202 203 204 208 210 212 215 219 225
App start regularAppStart Baseline
Mean: 0.014 ms
Stdev: 0.001 ms (5.8%)
Runs: 0.012695000506937504 0.012859000824391842 0.013020999729633331 0.013020999729633331 0.013345999643206596 0.013346999883651733 0.013508999720215797 0.01358999963849783 0.01358999963849783 0.013631000183522701 0.01375299971550703 0.013833999633789062 0.014078999869525433 0.014119000174105167 0.014119000174105167 0.014159999787807465 0.014159999787807465 0.014201000332832336 0.014241999946534634 0.014403999783098698 0.014444999396800995 0.01464799977838993 0.014649000018835068 0.014688999392092228 0.014810999855399132 0.014810999855399132 0.015054999850690365 0.015137000009417534 0.01537999976426363 0.016560999676585197

Current
Mean: 0.015 ms
Stdev: 0.000 ms (3.4%)
Runs: 0.013671999797224998 0.013957000337541103 0.013996999710798264 0.014078999869525433 0.014161000028252602 0.014201000332832336 0.014282000251114368 0.01428299956023693 0.014322000555694103 0.014322999864816666 0.0143630001693964 0.014403999783098698 0.01444500032812357 0.01444500032812357 0.014527000486850739 0.014566999860107899 0.014566999860107899 0.01460800040513277 0.01464799977838993 0.014770000241696835 0.014771000482141972 0.0148930000141263 0.0148930000141263 0.014933000318706036 0.01501499954611063 0.015177999623119831 0.01534000039100647 0.015461999922990799 0.015625 0.015786999836564064
App start nativeLaunch Baseline
Mean: 19.581 ms
Stdev: 1.914 ms (9.8%)
Runs: 17 17 17 18 18 18 18 18 18 18 18 19 19 19 19 19 19 20 20 20 20 20 20 21 21 21 22 22 23 23 25

Current
Mean: 19.419 ms
Stdev: 1.582 ms (8.1%)
Runs: 17 18 18 18 18 18 18 18 18 18 19 19 19 19 19 19 19 19 19 19 20 20 20 20 21 21 21 21 22 23 24
Open Search Page TTI Baseline
Mean: 607.748 ms
Stdev: 23.362 ms (3.8%)
Runs: 575.7556969998404 577.0270599992946 581.3484300002456 582.3508299998939 583.1001389995217 586.2287200000137 586.4050699993968 589.9490560004488 592.1600350001827 592.4473470002413 592.8690590001643 594.2888589994982 596.4401450008154 598.2228189995512 599.5055749993771 601.0457769995555 609.4406329998747 609.8101400006562 610.8331710007042 613.7771410001442 614.2000740002841 614.8839109996334 615.9808759996668 616.528809000738 617.290974999778 617.5190030001104 629.0914309993386 631.1853849999607 642.6490070000291 644.1139330007136 652.4335539992899 679.0430910000578

Current
Mean: 607.547 ms
Stdev: 17.077 ms (2.8%)
Runs: 580.4909259993583 582.3135580001399 584.8695069998503 585.6987719992176 589.3066000007093 591.2165529998019 592.1390789998695 593.4024259997532 594.4028320005164 596.9784349994734 599.3105470007285 599.8885510005057 600.9683440001681 603.7433270001784 605.3319509997964 607.5941160004586 607.6804610006511 608.0963130006567 608.6600750004873 610.0474049998447 610.0477300006896 610.0664059994742 610.4299320001155 610.6557620000094 611.0906580006704 620.415894000791 621.7171219997108 623.5894370004535 624.2824709992856 629.7654219996184 637.0272220000625 646.2230230001733 651.5867920005694

@OSBotify
Copy link
Contributor

OSBotify commented Feb 4, 2023

🚀 Deployed to staging by https://github.com/youssef-lr in version: 1.2.65-0 🚀

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

@OSBotify
Copy link
Contributor

OSBotify commented Feb 6, 2023

🚀 Deployed to production by https://github.com/mountiny in version: 1.2.65-2 🚀

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