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

allow Request money 'Description' to accept multiline #21664

Merged
merged 18 commits into from
Aug 28, 2023

Conversation

ahmedGaber93
Copy link
Contributor

@ahmedGaber93 ahmedGaber93 commented Jun 27, 2023

Details

Fixed Issues

$ #19872, #25780
PROPOSAL: #19872 (comment)

Tests

  1. Open any chat.
  2. Click (+) icon next the chat input then click request money.
  3. On description input write something long with line breaks.
  4. Verify that description input accept multlines and line break.
  5. Then click Save and Verify that the description field in request money confirm page is display in max two lines.
  6. Open the description field again and Verify that the description input is focued and the cursor position is at the end.
  7. Confirm the request money then go to the chat and open the "own thread" then open this request money thread and Verify that the report title is display in max one line.
  8. Create another request money by repeat steps 1, 2.
  9. Click button show more and write long merchant name.
  10. Complete the request money then go to the chat and open the "own thread" and Verify the long merchant name is break and not go outside the IOU preview.
  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

Same as Tests step.

  • 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 the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • 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 grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is 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 code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • 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.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
Screen.Recording.2023-08-23.at.11.32.22.AM.mov
Screen.Recording.2023-08-24.at.4.26.25.AM.mov
Mobile Web - Chrome
Screen.Recording.2023-08-23.at.12.34.57.PM.mov
Screen.Recording.2023-08-24.at.4.29.06.AM.mov
Mobile Web - Safari
Screen.Recording.2023-08-23.at.12.01.23.PM.mov
Screen.Recording.2023-08-24.at.4.38.05.AM.mov
Desktop
Screen.Recording.2023-08-23.at.11.39.48.AM.mov
Screen.Recording.2023-08-24.at.4.35.58.AM.mov
iOS
Screen.Recording.2023-08-23.at.11.59.30.AM.mov
Screen.Recording.2023-08-24.at.5.24.09.AM.mov
Android
Screen.Recording.2023-08-23.at.12.54.19.PM.mov
Screen.Recording.2023-08-24.at.4.30.45.AM.mov

@ahmedGaber93 ahmedGaber93 requested a review from a team as a code owner June 27, 2023 09:06
@melvin-bot melvin-bot bot removed the request for review from a team June 27, 2023 09:06
@melvin-bot
Copy link

melvin-bot bot commented Jun 27, 2023

@aimane-chnaif Please 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

@aimane-chnaif aimane-chnaif left a comment

Choose a reason for hiding this comment

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

Please remove any changes related to money request header. It will be handled in #19389 and out of scope for this PR.
Here, we should fix only input part.

@aimane-chnaif
Copy link
Contributor

@youssef-lr can this be separate issue? Same happens on task description from #19377 which you reviewed.

web.mov

Last line cursor overlaps with bottom border but fine when at least 1 letter

@ahmedGaber93
Copy link
Contributor Author

Please remove any changes related to money request header.

removed.
@aimane-chnaif

@aimane-chnaif
Copy link
Contributor

@ahmedGaber93 mSafari not working. can you investigate? I also tested task description input. There's another weird bug but at least multiline works.

msafari-bug.mov

@ahmedGaber93
Copy link
Contributor Author

@aimane-chnaif

@ahmedGaber93 mSafari not working. can you investigate?

This issue also happened with me in web.
After investigation, I found we have active subscribe on keyboard shortcut EnterKey in one of the previous page components.

MoneyRequestConfirmPage.js page has component MoneyRequestConfirmationList which use OptionsSelector component, and in OptionsSelector we subscribe to keyboard shortcut EnterKey.

this.unsubscribeEnter = KeyboardShortcut.subscribe(

and this subscription also work in inputs captureOnInputs = true

My proposal for this is:

Adding empty EnterKey subscription in MoneyRequestDescriptionPage, this empty subscription have by default captureOnInputs = false and shouldBubble = false which execute stopPropagation().

componentDidMount() {
    const enterConfig = CONST.KEYBOARD_SHORTCUTS.ENTER;
    this.unsubscribeEnter = KeyboardShortcut.subscribe(
        enterConfig.shortcutKey,
        () => {},
        enterConfig.descriptionKey,
        enterConfig.modifiers
    );
}

componentWillUnmount() {
    if (this.unsubscribeEnter) {
        this.unsubscribeEnter();
    }
}

@aimane-chnaif
Copy link
Contributor

This conflicts with #21661
@ahmedGaber93 please pull main and test again

@ahmedGaber93
Copy link
Contributor Author

This issue #21661 is related to tasks not money request, why it conflicts? @aimane-chnaif

@aimane-chnaif
Copy link
Contributor

This issue #21661 is related to tasks not money request, why it conflicts? @aimane-chnaif

I meant that's the reason why inconsistent behavior between task description input and money request description input

@ahmedGaber93
Copy link
Contributor Author

@aimane-chnaif I will check this #21664 (comment)
but about mSafari issue in this comment #21664 (comment) i think it is not the same of #21661 because submitOnEnter will cause form submit on enter press, but "shift + enter" will not cause new line, and this what I try to fix here #21664 (comment)

@aimane-chnaif
Copy link
Contributor

@ahmedGaber93 let's follow #21661 (comment)

@aimane-chnaif
Copy link
Contributor

submitOnEnter prop should do the magic

@ahmedGaber93
Copy link
Contributor Author

ahmedGaber93 commented Jun 29, 2023

@aimane-chnaif
Progress updates
#19135 done.
#20836 done.
#21205 done.
#21271 I think it is a known issue, and it also found in task description.
#21280 done.
#21347 done.
#21433 (same as #21280 above)
#21449 (same as #21271 above)

@aimane-chnaif
Copy link
Contributor

Thanks for update.
@youssef-lr let's hold our PR until above PRs to fix task description issues are deployed as it's double work.

@ahmedGaber93
Copy link
Contributor Author

@aimane-chnaif I applied the same fixes here #21664 (comment) in this PR, you can review now.

@aimane-chnaif
Copy link
Contributor

@ahmedGaber93 do you think all task description bugs are gone now except #21271?

@ahmedGaber93
Copy link
Contributor Author

ahmedGaber93 commented Jul 7, 2023

@aimane-chnaif yes we now have the same behavior in task description and request money description except "shift + enter" in web, it not return new line on request money description but do in task description in web. And here is my root cause and proposal for it #21664 (comment)

@aimane-chnaif
Copy link
Contributor

BUG: LHN alternativeText is also multilined

@aimane-chnaif Issue: offline - when create request money, the LHN "own item" display in multilined. root cause: incosistent between optimisticData (return all text) and backend data (return fist line only). fix: fix optimisticData lastMessageText by using ReportUtils.formatReportLastMessageText here

lastMessageText: iouAction.message[0].text,

Agree. This is hidden bug and we haven't noticed before enabling multiline.

@ahmedGaber93
Copy link
Contributor Author

@aimane-chnaif

BUG: LHN alternativeText is also multilined

Fix pushed

It seems text is collapsed too early

Can't reproduce it on native android

Screenshot 2023-08-24 at 3 53 19 AM

@ahmedGaber93
Copy link
Contributor Author

Yep, but the fix might be similar

@mountiny, the fix of issue #25780 has been pushed to this PR, and the Tests step and screenshots are updated.

@mountiny
Copy link
Contributor

thanks

@@ -116,7 +116,7 @@ function buildOnyxDataForMoneyRequest(
key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport.reportID}`,
value: {
...iouReport,
lastMessageText: iouAction.message[0].text,
lastMessageText: ReportUtils.formatReportLastMessageText(iouAction.message[0].text),
Copy link
Contributor

Choose a reason for hiding this comment

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

Apply this to Split bill as well

Screenshot 2023-08-25 at 12 50 13 PM

Copy link
Contributor

@aimane-chnaif aimane-chnaif Aug 25, 2023

Choose a reason for hiding this comment

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

Actually I think this can be separate issue to fix inconsistency between optimistic data and backend data for last message text with multiline description.
Can't we just prevent wrap here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can't we just prevent wrap here?

Are you mean remove new lines "\n" from message text?
If you mean that the lastMessageText will not be inconsistent with backend, because backend return only first line of message text.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we just prevent wrap here?

I meant to keep that optimistic value as is now but just fix display issue of wrapped

Copy link
Contributor Author

@ahmedGaber93 ahmedGaber93 Aug 25, 2023

Choose a reason for hiding this comment

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

the wrap happened here because numberOfLines={1} does not work as expected when <Text/> contains \n and whiteSpace: 'pre' just not break the long lines but not affected on \n

For that, we can fix it by replace styles.pre with styles.noWrap here

const alternateTextStyle = StyleUtils.combineStyles(
props.viewMode === CONST.OPTION_MODE.COMPACT
? [textStyle, styles.optionAlternateText, styles.pre, styles.textLabelSupporting, styles.optionAlternateTextCompact, styles.ml2]
: [textStyle, styles.optionAlternateText, styles.pre, styles.textLabelSupporting],
props.style,
);

This will remove the new lines "\n" from message text and fix the wrap issue, but inconsistency with backend will still issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Workaround cannot be a quick fix.

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 can't find a quick fix right now. What is the next step now?

  • use styles.noWrap and fix wrap issue partially with inconsistent result on iOS.
  • do nothing and keep wrap issue separately?

Copy link
Contributor

Choose a reason for hiding this comment

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

do nothing and keep wrap issue separately?

We can't do this because it looks weird and our PR might need to be reverted.

use styles.noWrap and fix wrap issue partially with inconsistent result on iOS.

This is still concerned but we would consider this not a deploy blocker I believe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I update the code to use styles.noWrap

Copy link
Contributor

Choose a reason for hiding this comment

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

styles.noWrap caused regression - #27586

@aimane-chnaif
Copy link
Contributor

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 the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • 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 grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is 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 code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • 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 the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • 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.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • 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
mchrome.mov
Mobile Web - Safari
msafari.mov
Desktop
desktop.mov
iOS
ios.mov
Android
android.mov

Copy link
Contributor

@aimane-chnaif aimane-chnaif left a comment

Choose a reason for hiding this comment

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

Follow up issues:

  • iOS alternativeText in LHN shows only first line, while all other platforms shows full text in one line (... at the end if overflows) (allow Request money 'Description' to accept multiline #21664 (comment))
  • LHN alternativeText, report header title don't preserve spaces and tabs (caused by replacing pre with nowrap)
  • inconsistent report.lastMessageText between optimistic data (full text) and backend (only first line)

Copy link
Contributor

@stitesExpensify stitesExpensify left a comment

Choose a reason for hiding this comment

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

LGTM! Just one small grammatical change

);
}

unSubscribeToKeyboardShortcut() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
unSubscribeToKeyboardShortcut() {
unSubscribeFromKeyboardShortcut() {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed

Copy link
Contributor

@stitesExpensify stitesExpensify left a comment

Choose a reason for hiding this comment

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

LGTM!

@stitesExpensify stitesExpensify merged commit d42967a into Expensify:main Aug 28, 2023
14 checks passed
@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/stitesExpensify in version: 1.3.59-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/stitesExpensify in version: 1.3.60-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/stitesExpensify in version: 1.3.60-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/luacmartins in version: 1.3.59-5 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/luacmartins in version: 1.3.60-3 🚀

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

@@ -51,7 +51,7 @@ function DisplayNamesWithToolTip(props) {
return (
// Tokenization of string only support prop numberOfLines on Web
<Text
style={[...props.textStyles, styles.pRelative]}
style={[...props.textStyles, styles.pRelative, props.numberOfLines === 1 ? styles.noWrap : {}]}
Copy link
Contributor

Choose a reason for hiding this comment

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

styles.noWrap is not needed here #32555 (comment)

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.

7 participants