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

Send button is active when message has spaces, but does not send it #8064

Merged
merged 1 commit into from
Mar 10, 2022
Merged

Send button is active when message has spaces, but does not send it #8064

merged 1 commit into from
Mar 10, 2022

Conversation

mollfpr
Copy link
Contributor

@mollfpr mollfpr commented Mar 10, 2022

Details

  1. Add this.updateComment(this.comment); to componentDidMount so the comment state will be check and update the isCommentEmpty state, if empty the button will be disable after the page load
  2. trim() everytime updateComment() called and removes whitespace from both sides strings
  3. this.textInput.selectionStart === 0 only to show trigger box edit if cursor position at start position

Fixed Issues

$ #7965

Tests

  1. Open a chat
  2. Verify that the button state is not active if messages on input text is empty
  3. Try to add space or newline and verify the button state is not active
  4. [Web/Desktop] Try to press the key arrow up and verify the edit box is triggered
  5. [Web/Desktop] Try to add spaces or newline, press key arrow up and verify if cursor position at start and arrow up key pressed once more will trigger edit box
  • Verify that no errors appear in the JS console

PR Review Checklist

Contributor (PR Author) Checklist

  • I verified the PR has a small number of commits behind main
  • 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 clearly indicated the environment tests should be run in (Staging vs Production)
  • I wrote testing steps that cover success & fail scenarios (if applicable)
  • I included screenshots or videos for tests on all platforms
  • I ran the tests & veryfy they passed on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors related to changes in this PR
  • I followed proper code patterns (see Reviewing the code)
    • I added comments when the code was not self explanatory
    • I put all copy / text shown in the product in all src/languages/* files (if applicable)
    • I followed proper naming convention for platform-specific files (if applicable)
    • I followed style guidelines (in Styling.md) for all style edits I made
    • I followed the JSDocs style guidelines (in STYLE.md)
  • 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 corroborated the UI performance was not affected (the performance is the same than main branch)
  • If I created a new component I verified that a similar component doesn't exist in the codebase

PR Reviewer Checklist

  • I verified the PR has a small number of commits behind main
  • 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 testing environment is mentioned in the test steps
  • I verified testing steps cover success & fail scenarios (if applicable)
  • 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 related to changes in this PR
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified comments were added when the code was not self explanatory
    • I verified any copy / text shown in the product was added in all src/languages/* files (if applicable)
    • I verified proper naming convention for platform-specific files was followed (if applicable)
    • I verified style guidelines were followed
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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 the UI performance was not affected (the performance is the same than main branch)
  • If a new component is created I verified that a similar component doesn't exist in the codebase

QA Steps

  1. Open a chat
  2. Verify that the button state is not active if messages on input text is empty
  3. Try to add space or newline and verify the button state is not active
  4. [Web/Desktop] Try to press the key arrow up and verify the edit box is triggered
  5. [Web/Desktop] Try to add spaces or newline, press key arrow up and verify if cursor position at start and arrow up key pressed once more will trigger edit box
  • Verify that no errors appear in the JS console

Screenshots

Web

Screen.Recording.2022-03-08.at.08.33.59.mov

Mobile Web

Screen.Recording.2022-03-08.at.08.45.13.mov

Desktop

Screen.Recording.2022-03-08.at.08.35.03.mov
Screen.Recording.2022-03-08.at.15.59.52.mov

iOS

Screen.Recording.2022-03-08.at.08.41.51.mov

Android

Screen.Recording.2022-03-08.at.15.37.50.mov

@mollfpr mollfpr requested a review from a team as a code owner March 10, 2022 04:37
@MelvinBot MelvinBot requested review from NikkiWines and rushatgabhane and removed request for a team March 10, 2022 04:37
@mollfpr
Copy link
Contributor Author

mollfpr commented Mar 10, 2022

re-create from #8036 (comment)

Copy link
Member

@rushatgabhane rushatgabhane left a comment

Choose a reason for hiding this comment

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

@NikkiWines LGTM!

@rushatgabhane
Copy link
Member

Commenting since I can't edit the PR

PR Reviewer Checklist

  • I verified the PR has a small number of commits behind main
  • 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 testing environment is mentioned in the test steps
  • I verified testing steps cover success & fail scenarios (if applicable)
  • 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 related to changes in this PR
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified comments were added when the code was not self explanatory
    • I verified any copy / text shown in the product was added in all src/languages/* files (if applicable)
    • I verified proper naming convention for platform-specific files was followed (if applicable)
    • I verified style guidelines were followed
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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 the UI performance was not affected (the performance is the same than main branch)
  • If a new component is created I verified that a similar component doesn't exist in the codebase

@NikkiWines NikkiWines assigned NikkiWines and mollfpr and unassigned NikkiWines Mar 10, 2022
Copy link
Contributor

@NikkiWines NikkiWines left a comment

Choose a reason for hiding this comment

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

:shipit:

@NikkiWines NikkiWines merged commit e3b47eb into Expensify:main Mar 10, 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.

@mollfpr mollfpr deleted the fix/send-button-active branch March 10, 2022 22:56
@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @NikkiWines in version: 1.1.42-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @chiragsalian in version: 1.1.42-6 🚀

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

Comment on lines -310 to +311
isCommentEmpty: newComment.length === 0,
isCommentEmpty: newComment.trim().length === 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

This caused a regression #21920. We used to relay on isCommentEmpty state being actually empty (length is 0) to move on to edit mode. This change made it possible to go into edit mode while having content on the Composer.

Copy link
Contributor Author

@mollfpr mollfpr Jul 13, 2023

Choose a reason for hiding this comment

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

@s77rt Could you elaborate on why that code causing the regression now? The code got changed on the next PR #8844

The logic has changed a lot since then, and the latest is !!newComment.match(/^(\s)*$/)

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure! The edit mode was accessible based on isCommentEmpty state. Before if the composer only contains empty spaces and you keep pressing the arrow up key, nothing will happen because the comment is not empty. But now the comment length is based on the trimmed version of that text so the composer appears empty and pressing the arrow up will get you into edit mode.

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.

None yet

5 participants