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

Add a color to the options in the picker when using Windows #13174

Merged
merged 3 commits into from
Nov 30, 2022

Conversation

pecanoro
Copy link
Contributor

@pecanoro pecanoro commented Nov 30, 2022

Details

Changing the colors of the items was really tricky since the component does not offer that possibility, I ended up fixing it by doing this: lawnstarter/react-native-picker-select#440

Fixed Issues

$ #13127
PROPOSAL: N/A

Tests

  • Verify that no errors appear in the JS console

On a Windows OS:

  1. Log in with any account
  2. Click on Profile
  3. Click on “Preferred Pronouns” or “Set my timezone automatically” option
  4. The list should not show empty and look like:

Monosnap Dashboard 2022-11-29 20-16-10

On a Mac OS:

  1. Log in with any account
  2. Click on Profile
  3. Click on “Preferred Pronouns” or “Set my timezone automatically” option
  4. The list should not show empty and look like:

Monosnap Monosnap 2022-11-29 20-01-06

Offline tests

QA Steps

  • Verify that no errors appear in the JS console

On a Windows OS:

  1. Log in with any account
  2. Click on Profile
  3. Click on “Preferred Pronouns” or “Set my timezone automatically” option
  4. The list should not show empty and look like:

Monosnap Dashboard 2022-11-29 20-16-10

On a Mac OS:

  1. Log in with any account
  2. Click on Profile
  3. Click on “Preferred Pronouns” or “Set my timezone automatically” option
  4. The list should not show empty and look like:
    Monosnap Monosnap 2022-11-29 20-01-06

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:
    • 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 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 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.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

PR Reviewer Checklist

The reviewer will copy/paste it into a new comment and complete it after the author checklist is completed

  • 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 expected offline behavior are in the Offline steps 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 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 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:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • 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 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 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
  • 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 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Web - Mac ![Monosnap Monosnap 2022-11-29 20-01-06](https://user-images.githubusercontent.com/6474442/204681959-b484fb09-c54a-411e-8d3a-96368f13dbd8.png)
Web - Windows ![image](https://user-images.githubusercontent.com/6474442/204683810-f3c0a17d-043f-4b0e-9193-9975cfd7bd69.png)
Mobile Web - Chrome ![chrome](https://user-images.githubusercontent.com/22219519/204686485-85fa6965-d42d-4c73-bb94-7e0e0644f4f5.png)
Web - Safari ![image](https://user-images.githubusercontent.com/6474442/204682103-29191087-3dd7-4dc9-b910-c2132173edaa.png)
Desktop ![Monosnap Monosnap 2022-11-29 20-19-23](https://user-images.githubusercontent.com/6474442/204684138-ae1ebf52-5675-4ca3-9941-cfd23e71841e.png)
iOS

ios

Android ![image](https://user-images.githubusercontent.com/6474442/204686193-6bc619fd-040d-46d3-899a-5a607bead4eb.png)

@pecanoro pecanoro self-assigned this Nov 30, 2022
@melvin-bot
Copy link

melvin-bot bot commented Nov 30, 2022

Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers!

src/components/Picker/index.js Outdated Show resolved Hide resolved

// Windows will reuse the text color of the select for each one of the options
// so we might need to color accordingly so it doesn't blend with the background.
if (getOperatingSystem() === CONST.OS.WINDOWS) {
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB I think that other platforms were unaffected by the dark theme change and override these styles, so checking for Windows might be unnecessary. That being said, it doesn't hurt to do so.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that is what I thought and I was going to leave it without it but I didn't want to cause a regression.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense. Let's keep it this way

Copy link
Contributor

Choose a reason for hiding this comment

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

Having the OS check here is the same as having a platform-specific check and our README shares pretty strong opinions about adding them:

Accordingly, don't even bother writing a platform-specific code block because you're just going to need to undo it.

Can you please take the time to remove this? My guess is the same as Carlos's and that having the color there isn't going to affect the other platforms, but let's be sure to test for regressions.

this.items = _.map(this.items, item => (
{
...item,
color: '#002140',
Copy link
Contributor

Choose a reason for hiding this comment

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

We should add this as a CONST

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally, it should be in the themes but Shawn said we don't have this one yet. DO you want me to add it as constant no matter what?

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like we have a colors switch PR coming up, based on this comment. I'll ping Georgia to clean this up once we deprecate this other colors.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would love it if this was moved to a constant or maybe to our style.variables. Anytime we leave code like this, even temporarily, that's opening chances for contributors to see it and copy it, assuming it's a good pattern to follow.

From what I've heard, we are not moving quickly on that theme-switcher, and even when they do, it will be hard to find this and fix it, so it could live here for a long time if someone forgets about it.

@github-actions
Copy link
Contributor

⚠️ ⚠️ Heads up! This pull request has the CP Staging label ⚠️ ⚠️
If you applied the CP Staging label before the PR was merged, the PR will be be immediately deployed to staging even if the open StagingDeployCash deploy checklist is locked.
However if you applied the CP Staging after the PR was merged it's possible it won't be CP'ed automatically. If you need it to be CP'ed to staging, tag a member of @Expensify/mobile-deployers to CP it manually, otherwise you can wait for it to go out with the next deploy.

Co-authored-by: Carlos Martins <cmartins@expensify.com>
@pecanoro pecanoro marked this pull request as ready for review November 30, 2022 01:24
@pecanoro pecanoro requested a review from a team as a code owner November 30, 2022 01:24
@melvin-bot melvin-bot bot requested review from madmax330 and rushatgabhane and removed request for a team November 30, 2022 01:24
@melvin-bot
Copy link

melvin-bot bot commented Nov 30, 2022

@rushatgabhane @madmax330 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]

Copy link
Contributor

@luacmartins luacmartins 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 tests well

@luacmartins
Copy link
Contributor

luacmartins commented Nov 30, 2022

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:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • 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 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 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 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Web

** Mac OS**
web

** Windows **
windows

Mobile Web - Chrome ![chrome](https://user-images.githubusercontent.com/22219519/204685166-7cb82ccf-4938-42ec-912c-e368c8191279.png)
Mobile Web - Safari

safari

Desktop desktop
iOS ![ios](https://user-images.githubusercontent.com/22219519/204685180-82f36625-5f66-4f07-ba65-41e3f4147034.png)
Android

android

if (getOperatingSystem() === CONST.OS.WINDOWS) {
this.placeholder = _.isEmpty(this.placeholder) ? {} : {
...this.placeholder,
color: '#002140',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For future reference, in case someone stumbles on this PR, we didn't create a constant for this because we'll have to clean it up anyways when the light theme is up soon.

@luacmartins
Copy link
Contributor

Checklists are complete! I'll merge this to fix the blocker!

@luacmartins luacmartins merged commit df97c3c into main Nov 30, 2022
@luacmartins luacmartins deleted the rocio-BackgroundColor branch November 30, 2022 01:40
OSBotify pushed a commit that referenced this pull request Nov 30, 2022
Add a color to the options in the picker when using Windows

(cherry picked from commit df97c3c)
OSBotify added a commit that referenced this pull request Nov 30, 2022
@OSBotify
Copy link
Contributor

🚀 Cherry-picked to staging by @luacmartins in version: 1.2.33-7 🚀

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

@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes.

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @luacmartins in version: 1.2.33-7 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @luacmartins in version: 1.2.33-7 🚀

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

Copy link
Contributor

@tgolen tgolen left a comment

Choose a reason for hiding this comment

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

Hi! Sorry to stop by here after-the-fact, but I did see a few things that I wanted to point out.

On a semi-related note, since windows is not a supported platform, this should have been a feature and not a bug.

}

componentDidMount() {
this.setDefaultValue();

// Windows will reuse the text color of the select for each one of the options
Copy link
Contributor

Choose a reason for hiding this comment

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

It's probably not very ideal to have this logic here and I think the constructor is a better place for it. The reason is, componentDidMount() isn't run until after it's rendered, but we want those values to be there before things are rendered.


// Windows will reuse the text color of the select for each one of the options
// so we might need to color accordingly so it doesn't blend with the background.
if (getOperatingSystem() === CONST.OS.WINDOWS) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Having the OS check here is the same as having a platform-specific check and our README shares pretty strong opinions about adding them:

Accordingly, don't even bother writing a platform-specific code block because you're just going to need to undo it.

Can you please take the time to remove this? My guess is the same as Carlos's and that having the color there isn't going to affect the other platforms, but let's be sure to test for regressions.

this.items = _.map(this.items, item => (
{
...item,
color: '#002140',
Copy link
Contributor

Choose a reason for hiding this comment

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

I would love it if this was moved to a constant or maybe to our style.variables. Anytime we leave code like this, even temporarily, that's opening chances for contributors to see it and copy it, assuming it's a good pattern to follow.

From what I've heard, we are not moving quickly on that theme-switcher, and even when they do, it will be hard to find this and fix it, so it could live here for a long time if someone forgets about it.

@pecanoro
Copy link
Contributor Author

pecanoro commented Dec 2, 2022

Sure, I can make all those changes, sorry about that!

@pecanoro
Copy link
Contributor Author

pecanoro commented Dec 2, 2022

I also brought up in #expensify-open-source the discussion about not supporting Windows since I find it interesting taking into account that is the most used OS.

@OSBotify
Copy link
Contributor

🚀 Cherry-picked to staging by https://github.com/AndrewGable in version: 1.3.28-2 🚀

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

@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes.

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/AndrewGable in version: 1.3.28-5 🚀

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.

4 participants