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

Fix display name and date alignment #14304

Merged
merged 15 commits into from
Jan 30, 2023
Merged

Fix display name and date alignment #14304

merged 15 commits into from
Jan 30, 2023

Conversation

luacmartins
Copy link
Contributor

@luacmartins luacmartins commented Jan 13, 2023

Details

Fix the display name and date alignments

Fixed Issues

$ #14269

Tests

  1. Go to any chat
  2. Verify that the display name and date are aligned at the bottom of the text
  • 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
    • 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

desktop

Mobile Web - Chrome

chrome

Mobile Web - Safari

safari

Desktop

desktop

iOS

ios

Android

android

@luacmartins luacmartins self-assigned this Jan 13, 2023
@luacmartins luacmartins changed the title Baseline align displayName and date Fix display name and date alignment Jan 13, 2023
@luacmartins luacmartins marked this pull request as ready for review January 13, 2023 21:58
@luacmartins luacmartins requested a review from a team as a code owner January 13, 2023 21:58
@melvin-bot melvin-bot bot requested review from MariaHCD and Santhosh-Sellavel and removed request for a team January 13, 2023 21:59
@melvin-bot
Copy link

melvin-bot bot commented Jan 13, 2023

@Santhosh-Sellavel @MariaHCD 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]

@Santhosh-Sellavel
Copy link
Collaborator

@Expensify/design or @shawnborton does it looks as expected?

Web

Screenshot 2023-01-15 at 11 02 19 PM

Desktop

Screenshot 2023-01-15 at 11 11 57 PM

Android

Screenshot 2023-01-15 at 11 13 43 PM

iOS

Screenshot 2023-01-15 at 11 17 04 PM

Android mWeb

Screenshot 2023-01-15 at 11 16 34 PM

iOS mWeb

Screenshot 2023-01-15 at 11 14 29 PM

@Santhosh-Sellavel
Copy link
Collaborator

@luacmartins PR Screenshots are not loading can you check?

lineHeight: variables.lineHeightXLarge,
paddingBottom: 4,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we want to get rid of the padding bottom. However, for image attachments, if the image attachment is the first thing in the message group (it comes right after the sender name) we should give it some top margin of say 4-8px.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just read the Slack thread linked to the issue and it seems like we also want to do some cleanup on the negative margins used for the message text, as well as add some padding for images. I'll add that to this PR.

That being said, I'm having issues aligning the sender name & date at the baseline. alignItems: 'baseline' is supported in RN and works well on browsers, but the Pressable component wrapping the sender name text is throwing off the alignment on iOS/android native since it's baseline is different from the text baseline. Here's how they behave:

iOS
ios

android
android

I've spent some time trying to work around this issue, but no luck so far. Any suggestions?

Copy link
Contributor

Choose a reason for hiding this comment

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

Take a look at the discussion from this one: #14148

We actually learned that baseline doesn't always work on Android so we might want to avoid that.

There was a proposal that seemed to fix the alignment by always making sure the big text (sender) and small text (timestamp) had the same lineheight and height. So maybe we could try that first?

Copy link
Contributor

Choose a reason for hiding this comment

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

So after seeing this, it does feel like the sender is too close to the message, but maybe that's because the negative margin is still there. So let me know once you start playing around with that stuff too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was a proposal that seemed to fix the alignment by always making sure the big text (sender) and small text (timestamp) had the same lineheight and height. So maybe we could try that first?

I tried this and the other solutions in that issue but none of them seem to work. Maybe I'm holding something wrong?

I'd appreciate any other suggestions as I'm struggling to find a solution that doesn't add any padding/margins to the text.

Copy link
Contributor Author

@luacmartins luacmartins Jan 23, 2023

Choose a reason for hiding this comment

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

@shawnborton I updated the branch with the following:

  1. Added lineHeight: 20px to the senders name and removed the bottom padding
  2. Added lineHeight: 16px and paddingTop: 4px to the timestamp

Now the header + single line message sums up to 40px and both seem to be aligned at the baseline:
Screenshot 2023-01-23 at 4 19 09 PM

Screenshot 2023-01-23 at 4 19 02 PM

In addition, I removed the negative margin from chatItemMessage and added a conditional 8px top margin to attachments when displayed with the header:

Screenshot 2023-01-23 at 4 27 41 PM

Let me know what you think!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aneequeahmad let's see what @shawnborton says about my changes above!

Copy link
Contributor

Choose a reason for hiding this comment

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

That feels pretty great to me! Thanks for pushing through this one and getting to a good solution!

Copy link
Contributor

Choose a reason for hiding this comment

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

@luacmartins Code changes looks good to me too. That's a pretty neat solution. @shawnborton Thank-you for your suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you both for the help!

Copy link
Contributor

@MariaHCD MariaHCD left a comment

Choose a reason for hiding this comment

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

Fixed the screenshots in the OP :) The padding bottom does look a bit too much in @Santhosh-Sellavel's screenshots but it looks fine when I tested locally on:

Web:

Screenshot 2023-01-16 at 1 01 43 PM

Desktop:

Screenshot 2023-01-16 at 1 03 58 PM

MariaHCD
MariaHCD previously approved these changes Jan 24, 2023
Copy link
Contributor

@MariaHCD MariaHCD left a comment

Choose a reason for hiding this comment

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

LGTM!

@luacmartins
Copy link
Contributor Author

@Santhosh-Sellavel all yours for review!

@Santhosh-Sellavel
Copy link
Collaborator

Screenshots/Videos

Web Screenshot 2023-01-24 at 10 56 56 PM
Mobile Web - Chrome

Screenshot_1674583374

Mobile Web - Safari

Simulator Screen Shot - iPhone 14 - 2023-01-24 at 23 03 16

Desktop Screenshot 2023-01-24 at 10 57 57 PM
iOS

Simulator Screen Shot - iPhone 14 - 2023-01-24 at 23 33 19

Android

Screenshot_1674583652

The latest screenshots does it looks good? cc: @shawnborton @luacmartins @MariaHCD

@Santhosh-Sellavel
Copy link
Collaborator

Santhosh-Sellavel commented Jan 24, 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.

@Santhosh-Sellavel
Copy link
Collaborator

@luacmartins Can you update the latest screenshots in the PR?

@luacmartins
Copy link
Contributor Author

@Santhosh-Sellavel done!

@Santhosh-Sellavel
Copy link
Collaborator

@luacmartins have you checked this #14304 (comment)?

Seem still something is off to me, is it just to me?

@Santhosh-Sellavel
Copy link
Collaborator

I'll test again tomorrow!

@shawnborton
Copy link
Contributor

Hmm yeah, based on those screenshots, it does look like the timestamp sits below the sender:
image

image

@aneequeahmad
Copy link
Contributor

@shawnborton I just checked this branch it seems fine at my end. Strange.

Screen Shot 2023-01-25 at 4 59 20 PM

@shawnborton
Copy link
Contributor

Hmm @Santhosh-Sellavel any idea what's causing this?

It seems like between this issue and the other alignment issue, we're getting a lot of inconsistencies in various platforms/screenshots.

@luacmartins
Copy link
Contributor Author

hmm I'm seeing a small alignment issue on mWeb Chrome and Safari 🤔 Not sure what's causing it yet.

@aneequeahmad
Copy link
Contributor

aneequeahmad commented Jan 26, 2023

@luacmartins i just debugged and fixed the issue. Actually there is not need to add lineHeight and need to reduce paddingTop: 4 to paddingTop: 2.

Also verified it doesn't cause regression on Web.

cc: @shawnborton

Code Changes:

     chatItemMessageHeaderTimestamp: {
         flexShrink: 0,
         color: themeColors.textSupporting,
         fontSize: variables.fontSizeSmall,
-        paddingTop: 4,
-        lineHeight: variables.lineHeightNormal,
+        paddingTop: 2,
     },

Screen Shot 2023-01-26 at 5 18 49 AM

@Santhosh-Sellavel
Copy link
Collaborator

Santhosh-Sellavel commented Jan 26, 2023

@luacmartins

I find all platforms are off, i.e compare this screenshots with screenshots in the PR description.

@MariaHCD Can you post what you see on Web & Desktop?

Honestly, I'm confused about what's happening here, before worrying about Inconsistent between platforms, there is an inconsistency between author screenshots & reviewer screenshots 😕 .

cc: @shawnborton

@luacmartins
Copy link
Contributor Author

I updated the PR and screenshots using this suggestion. Ready for another review!

@shawnborton
Copy link
Contributor

That feels pretty good to me. It might not be perfectly baseline aligned, but I think it's a good improvement and it feels consistent across platforms.

Copy link
Contributor

@MariaHCD MariaHCD left a comment

Choose a reason for hiding this comment

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

LGTM. Tested on web and desktop:

Screenshot 2023-01-27 at 3 20 21 PM
Screenshot 2023-01-27 at 3 19 59 PM
Screenshot 2023-01-27 at 3 19 20 PM
Screenshot 2023-01-27 at 3 18 56 PM

@Santhosh-Sellavel
Copy link
Collaborator

Santhosh-Sellavel commented Jan 27, 2023

Screenshots/Videos

Web Screenshot 2023-01-28 at 3 20 44 AM Screenshot 2023-01-28 at 3 20 27 AM
Mobile Web - Chrome

Screenshot_1674856827
Screenshot 2023-01-28 at 3 30 23 AM

Mobile Web - Safari Screenshot 2023-01-28 at 3 28 25 AM ![Simulator Screen Shot - iPhone 14 - 2023-01-28 at 03 28 27](https://user-images.githubusercontent.com/85645967/215210821-fa1b7175-9dea-4555-af1e-cd6a5439eb12.png)
Desktop Screenshot 2023-01-28 at 3 23 44 AM Screenshot 2023-01-28 at 3 24 03 AM
iOS

Simulator Screen Shot - iPhone 14 - 2023-01-28 at 03 31 27

Android

Screenshot_1674856410

@Santhosh-Sellavel
Copy link
Collaborator

Here are new screenshots can you confirm this looks @shawnborton @luacmartins

@shawnborton
Copy link
Contributor

Yup, this feels pretty good to me!

@luacmartins
Copy link
Contributor Author

@Santhosh-Sellavel seems like this looks good now. Can you complete the checklist please?

@Santhosh-Sellavel
Copy link
Collaborator

Yes will do!

Copy link
Collaborator

@Santhosh-Sellavel Santhosh-Sellavel left a comment

Choose a reason for hiding this comment

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

LGTM thanks, everyone!

@luacmartins luacmartins merged commit 83371f7 into main Jan 30, 2023
@luacmartins luacmartins deleted the cmartins-alignBaseline branch January 30, 2023 21:37
@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 https://github.com/luacmartins in version: 1.2.63-0 🚀

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

@OSBotify
Copy link
Contributor

OSBotify commented Feb 1, 2023

🚀 Deployed to production by https://github.com/thienlnam in version: 1.2.63-0 🚀

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