Skip to content

[HOLD for PR #42892] trim leading and trailing CR LF during paste into composer - #41265

Closed
kpadmanabhan wants to merge 7 commits into
Expensify:mainfrom
kpadmanabhan:39971_sanitize_pasted_text_CRLF
Closed

kpadmanabhan wants to merge 7 commits into
Expensify:mainfrom
kpadmanabhan:39971_sanitize_pasted_text_CRLF

Conversation

@kpadmanabhan

@kpadmanabhan kpadmanabhan commented Apr 29, 2024 •

Copy link
Copy Markdown

@jayeshmangwani / @roryabraham

Details

Trimming leading and trailing CR LF characters from pasted content of composer text, so that it does not hamper the flow of paste event triggering and handling in Newdot composer.

Fixed Issues

$ #39971
PROPOSAL: #39971 (comment)

Tests

  1. Make sure composer field is empty
  2. Copy below mentioned text(s) into clipboard
  3. Paste it in composer and check if "Send" button is enabled and clickable

Text(s) tested:

  • Single line without trailing CR LF
This is a single line text.
  • Single line with trailing CR LF
This is single line text but with newline at the end of line.

  • Single line with leading CR LF

This is single line text but with newline at the start of line.
  • Single line with leading and trailing CR LF

This is single line text but with newline at the start and end of line.

  • Text with newline character in text content
Text with newline character \n in text content.\n
  • Multi line without trailing CR LF
During communication with Expensify, you will come across a variety of acronyms used by our team. While acronyms can be
 useful, they cease to be the moment they are not known to the receiver. As such, we wanted to create a list here of our most 
commonly used acronyms and what they're referring to. Lastly, please never hesitate to ask in Slack or the GH issue if there are 
any that are not understood/known!
  • Multi line with trailing CR LF
During communication with Expensify, you will come across a variety of acronyms used by our team. While acronyms can be 
useful, they cease to be the moment they are not known to the receiver. As such, we wanted to create a list here of our most 
commonly used acronyms and what they're referring to. Lastly, please never hesitate to ask in Slack or the GH issue if there are 
any that are not understood/known!

  • Numbered text
    1. Proposing steps to take for a regression test to ensure the bug doesn't occur again (For information on how to successfully complete this, head [here](https://github.com/Expensify/App/blob/main/contributingGuides/REGRESSION_TEST_BEST_PRACTICES.md)).
    2. Identifying and noting the offending PR that caused the bug (if any).
    3. Commenting on the offending PR to note the bug it caused and why (if applicable).
    4. Starting a conversation on if any additional steps should be taken to prevent further bugs similar to the one fixed from occurring again. 
    5. 
  • Code comment
    ```
    [commit]
        gpgsign = true
    [user]
        email = <Your GH account email>
        name = <Your Name>
        signingkey = <your_signing_key>
    [gpg]
        program = gpg
    ```
  • Bulleted text
- If you have made a change to your pull request and are ready for another review, leave a comment that says "Updated" on the pull request  itself.
- Please keep the conversation in GitHub, and do not ping individual reviewers in Slack or Upwork to get their attention.
- Pull Request reviews can sometimes take a few days. If your pull request has not been addressed after four days, please let us know via the #expensify-open-source Slack channel.
  • Html text
<input onpaste={(event:ClipboardEvent<HTMLInputElement>) => pasteMock(event)} />
  • Multi-line html text
<div align="center">
    <a href="https://new.expensify.com">
        <img src="https://raw.githubusercontent.com/Expensify/App/main/web/favicon.png" width="64" height="64" alt="New Expensify Icon">
    </a>
    <h1>
        <a href="https://new.expensify.com">
            New Expensify
        </a>
    </h1>
</div>

  • Copy paste an image

  • Verify that no errors appear in the JS console

Offline tests

Same as above.

QA Steps

Same as above.
Any pasted text (copy to clipboard and paste it into the composer) containing leading or trailing newline Carriage Return (CR) and Line Feed (LF) characters must enable "Send" button of composer.

  • 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: mWeb Chrome
    • iOS: Native
    • iOS: mWeb 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 either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • 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 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(theme.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 the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • 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.

Screenshots/Videos

Android: Native
Screen.Recording.2024-05-23.at.19.59.38.mov
Android: mWeb Chrome
Screen.Recording.2024-05-23.at.20.33.45.mov
iOS: Native
Screen.Recording.2024-05-20.at.19.43.17_1080p.mov
iOS: mWeb Safari
Screen.Recording.2024-05-21.at.21.32.16_720p_updated.mov
MacOS: Chrome / Safari
Screen.Recording.2024-05-20.at.01.10.58_480p.mov
MacOS: Desktop
Screen.Recording.2024-05-20.at.00.55.19_1080p.mov

@kpadmanabhan
kpadmanabhan requested a review from a team as a code owner April 29, 2024 22:59
@melvin-bot
melvin-bot Bot requested review from jayeshmangwani and removed request for a team April 29, 2024 22:59
@melvin-bot

melvin-bot Bot commented Apr 29, 2024

Copy link
Copy Markdown

@jayeshmangwani 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]

@github-actions

github-actions Bot commented Apr 29, 2024 •

Copy link
Copy Markdown
Contributor

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@kpadmanabhan
kpadmanabhan marked this pull request as draft April 29, 2024 23:26
@kpadmanabhan

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@jayeshmangwani

Copy link
Copy Markdown
Contributor

Hey @kpadmanabhan , Are you able to run the app on all the platforms? Please fill in all the missing checkboxes from the description that can be finished. And please write the unit test for the useHtmlPaste function.

@kpadmanabhan

kpadmanabhan commented May 5, 2024 •

Copy link
Copy Markdown
Author

@jayeshmangwani Thanks for following up and sorry for delay in update here. Even though my change is not OS dependent, I understand that I must test it in all env.
I was using windows (Windows Subsystem for Linux) till now. Just got hold of a Macbook. Setting up env in that. Will update soon here.

Btw, whom can I contact for a Mapbox key?

@jayeshmangwani

Copy link
Copy Markdown
Contributor

@kpadmanabhan For the key, I have responded in Slack. If you need any help in setting it up, please hit me up.

@jayeshmangwani

Copy link
Copy Markdown
Contributor

Hey @kpadmanabhan, is there any update for us? If you are stuck anywhere, you can comment here or on #expensify-open-source.

@jayeshmangwani

Copy link
Copy Markdown
Contributor

@kpadmanabhan bump for the update

@roryabraham

Copy link
Copy Markdown
Contributor

Seems like this PR is abandoned

@jayeshmangwani

Copy link
Copy Markdown
Contributor

Yes @roryabraham , it looks like the contributor is not active

@kpadmanabhan

Copy link
Copy Markdown
Author

@roryabraham / @jayeshmangwani : apologies for this. I was quite unwell for past couple of weeks. Sorry for no updates. Resuming work today. Fixes should be addressed by today e.o.d.

@kpadmanabhan

Copy link
Copy Markdown
Author

Testing on iOS (native and web), macOS (chrome web and desktop app) complete. Results attached to PR.
Facing challenges with Android testing on Pixel simulator. Though script brings up android simulator, it executes and then stops the emulator by itself before launching the app with no visible error messages in console.

Where can I find detailed logging on whats going wrong with the launch of simulator and starting the app?

@roryabraham

Copy link
Copy Markdown
Contributor

I find I often have to delete the emulator and create new ones. Or if you have access to a physical Android device I find that to be much more reliable than emulators.

@kpadmanabhan

Copy link
Copy Markdown
Author

Now getting below error.
@roryabraham / @jayeshmangwani Any thioughts?

Warning: SDK processing. This version only understands SDK XML versions up to 3 but an SDK XML file of version 4 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.
Warning: SDK processing. This version only understands SDK XML versions up to 3 but an SDK XML file of version 4 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.
CMake Deprecation Warning at CMakeLists.txt:42 (cmake_policy):
  The OLD behavior for policy CMP0026 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Warning at /Users/archanavenkat/Library/Android/sdk/cmake/3.22.1/share/cmake-3.22/Modules/Platform/Darwin-Initialize.cmake:303 (message):
  Ignoring CMAKE_OSX_SYSROOT value:

   /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk

  because the directory does not exist.
Call Stack (most recent call first):
  /Users/archanavenkat/Library/Android/sdk/cmake/3.22.1/share/cmake-3.22/Modules/CMakeSystemSpecificInitialize.cmake:21 (include)
  CMakeLists.txt:64 (project)


CMake Error at /Users/archanavenkat/Library/Android/sdk/cmake/3.22.1/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler

    "/Library/Developer/CommandLineTools/usr/bin/cc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /Users/archanavenkat/krishnan/App/node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/usr/bin/make -f Makefile cmTC_91bc9/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make  -f CMakeFiles/cmTC_91bc9.dir/build.make CMakeFiles/cmTC_91bc9.dir/build
    Building C object CMakeFiles/cmTC_91bc9.dir/testCCompiler.c.o
    /Library/Developer/CommandLineTools/usr/bin/cc   -arch arm64 -mmacosx-version-min=11.3 -MD -MT CMakeFiles/cmTC_91bc9.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_91bc9.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_91bc9.dir/testCCompiler.c.o -c /Users/archanavenkat/krishnan/App/node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/CMakeFiles/CMakeTmp/testCCompiler.c
    Linking C executable cmTC_91bc9
    /Users/archanavenkat/Library/Android/sdk/cmake/3.22.1/bin/cmake -E cmake_link_script CMakeFiles/cmTC_91bc9.dir/link.txt --verbose=1
    /Library/Developer/CommandLineTools/usr/bin/cc  -arch arm64 -mmacosx-version-min=11.3 -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_91bc9.dir/testCCompiler.c.o -o cmTC_91bc9 
    ld: library 'System' not found
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make[1]: *** [cmTC_91bc9] Error 1
    make: *** [cmTC_91bc9/fast] Error 2
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:64 (project)



FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native:packages:react-native:ReactAndroid:hermes-engine:configureBuildForHermes'.
> Process 'command '/Users/archanavenkat/Library/Android/sdk//cmake/3.22.1/bin/cmake'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 7m 4s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDevelopmentDebug -PreactNativeDevServerPort=8081
Warning: SDK processing. This version only understands SDK XML versions up to 3 but an SDK XML file of version 4 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.
Warning: SDK processing. This version only understands SDK XML versions up to 3 but an SDK XML file of version 4 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.
CMake Deprecation Warning at CMakeLists.txt:42 (cmake_policy): The OLD behavior for policy CMP0026 will be removed from a future version of CMake. The cmake-policies(7) manual explains that the OLD behaviors of all policies are deprecated and that a policy should be set to OLD only under specific short-term circumstances. Projects should be ported to the NEW behavior and not rely on setting a policy to OLD. CMake Warning at /Users/archanavenkat/Library/Android/sdk/cmake/3.22.1/share/cmake-3.22/Modules/Platform/Darwin-Initialize.cmake:303 (message): Ignoring CMAKE_OSX_SYSROOT value: /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk because the directory does not exist.
Call Stack (most recent call first): /Users/archanavenkat/Library/Android/sdk/cmake/3.22.1/share/cmake-3.22/Modules/CMakeSystemSpecificInitialize.cmake:21 (include) CMakeLists.txt:64 (project) CMake Error at /Users/archanavenkat/Library/Android/sdk/cmake/3.22.1/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message): The C compiler "/Library/Developer/CommandLineTools/usr/bin/cc" is not able to compile a simple test program. It fails with the following output: Change Dir: /Users/archanavenkat/krishnan/App/node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/CMakeFiles/CMakeTmp Run Build Command(s):/usr/bin/make -f Makefile cmTC_91bc9/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_91bc9.dir/build.make CMakeFiles/cmTC_91bc9.dir/build Building C object CMakeFiles/cmTC_91bc9.dir/testCCompiler.c.o /Library/Developer/CommandLineTools/usr/bin/cc -arch arm64 -mmacosx-version-min=11.3 -MD -MT CMakeFiles/cmTC_91bc9.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_91bc9.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_91bc9.dir/testCCompiler.c.o -c /Users/archanavenkat/krishnan/App/node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/CMakeFiles/CMakeTmp/testCCompiler.c Linking C executable cmTC_91bc9 /Users/archanavenkat/Library/Android/sdk/cmake/3.22.1/bin/cmake -E cmake_link_script CMakeFiles/cmTC_91bc9.dir/link.txt --verbose=1 /Library/Developer/CommandLineTools/usr/bin/cc -arch arm64 -mmacosx-version-min=11.3 -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_91bc9.dir/testCCompiler.c.o -o cmTC_91bc9 ld: library 'System' not found clang: error: linker command failed with exit code 1 (use -v to see invocation) make[1]: *** [cmTC_91bc9] Error 1 make: *** [cmTC_91bc9/fast] Error 2 CMake will not be able to correctly generate this project.
Call Stack (most recent call first): CMakeLists.txt:64 (project) FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':react-native:packages:react-native:ReactAndroid:hermes-engine:configureBuildForHermes'.
> Process 'command '/Users/archanavenkat/Library/Android/sdk//cmake/3.22.1/bin/cmake'' finished with non-zero exit value 1 * Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org. BUILD FAILED in 7m 4s.
info Run CLI with --verbose flag for more details.

@jayeshmangwani

Copy link
Copy Markdown
Contributor

@kpadmanabhan I haven't gotten the above issue, but I got an issue on Android that was solved by removing the android/app/.cxx folder and then re-run

@jayeshmangwani

Copy link
Copy Markdown
Contributor

@kpadmanabhan Any luck with running on Android ?

If you still facing the issue, then I would suggest leave the Android And Android mWeb testing for me, I will take care of it, You can focus on remaining part of the PR, And then you can fix your Android environment later.

@kpadmanabhan
kpadmanabhan marked this pull request as ready for review May 23, 2024 18:36
@kpadmanabhan

Copy link
Copy Markdown
Author

@jayeshmangwani : thanks for your quick support to investigate the setup. I have fixed the setup and am able to run in Android as well. Updated results of all in the template. Kindly review.

@jayeshmangwani

Copy link
Copy Markdown
Contributor

@kpadmanabhan You need to sign the all commits, and lint code is failing here FIX that, remove the commit from a user name Archana Venkataraman

Comment thread src/hooks/useHtmlPaste/index.ts Outdated
@kpadmanabhan
kpadmanabhan force-pushed the 39971_sanitize_pasted_text_CRLF branch from c3c26ea to 88e08a0 Compare May 24, 2024 20:20
Comment thread src/hooks/useHtmlPaste/index.ts Outdated
@jayeshmangwani

Copy link
Copy Markdown
Contributor

@kpadmanabhan Can we please add the unit test for useHtmlPaste ?

@jayeshmangwani

Copy link
Copy Markdown
Contributor

Locally, lint is failing for me for some reason. Does lint pass for you?

@kpadmanabhan

Copy link
Copy Markdown
Author

Locally, lint is failing for me for some reason. Does lint pass for you?

yes. lint is passing for me locally. did you pull latest?

(base) XXX@XX-MacBook-Air App % npm run lint

> new.expensify@1.4.75-0 lint
> eslint . --max-warnings=0 --cache --cache-location=node_modules/.cache/eslint

(base) XXX@XX-MacBook-Air App % 

spacing fix

Co-authored-by: Jayesh Mangwani <35371050+jayeshmangwani@users.noreply.github.com>
@jayeshmangwani

Copy link
Copy Markdown
Contributor

yes. lint is passing for me locally. did you pull latest?

Yes, it tested in the latest pull; maybe it's only for me

@kpadmanabhan

Copy link
Copy Markdown
Author

@jayeshmangwani : added unit tests in StringUtils as this is a regex check. Pls re-review.

@jayeshmangwani

Copy link
Copy Markdown
Contributor

Thanks @kpadmanabhan for adding the unit tests; I was testing this PR and one scenario I missed before, and I want to confirm before we merge the PR.

Right now, in the main branch in composer, when we copy the multi newline and paste it between the large message, then new lines don't lose the originally copied newlines; and now, after adding the above changes in this PR, when we copy the muli new lines text between the large message then leading and trailing newlines got removed, below I am adding two videos for the visual effect of the changes between main and this PR
cc: @roryabraham

Main branch
new-lines-main.mov
Existing PR
new-lines-after-this-PR.mov

@kpadmanabhan

Copy link
Copy Markdown
Author

Thanks @kpadmanabhan for adding the unit tests; I was testing this PR and one scenario I missed before, and I want to confirm before we merge the PR.

Right now, in the main branch in composer, when we copy the multi newline and paste it between the large message, then new lines don't lose the originally copied newlines; and now, after adding the above changes in this PR, when we copy the muli new lines text between the large message then leading and trailing newlines got removed, below I am adding two videos for the visual effect of the changes between main and this PR cc: @roryabraham

Main branch
new-lines-main.mov
Existing PR
new-lines-after-this-PR.mov

@jayeshmangwani : thanks for this test.
the reason for this behaiour is that in the hooks when we paste a text, we only have access to the pasted text and not the text already present in the composer. if the trailing newlines are not removed, then the event does not get propagated to composer, resulting in send button not getting enabled.

ONYX update in ComposerWithSuggestions.tsx is not fired through onChangeText event and hence draft report is not saved to ONYX.
This is because isCommentEmpty returns TRUE.

@jayeshmangwani

Copy link
Copy Markdown
Contributor

if the trailing newlines are not removed, then the event does not get propagated to composer, resulting in send button not getting enabled.

There must be something wrong with the existing code event that should be fired

@kpadmanabhan

Copy link
Copy Markdown
Author

if the trailing newlines are not removed, then the event does not get propagated to composer, resulting in send button not getting enabled.

There must be something wrong with the existing code event that should be fired

the reason being that start and end of selection range from the node are detected as 0 due to the presence of trailing newline and hence propagation of event does not happen to composer handlePaste().

@roryabraham

Copy link
Copy Markdown
Contributor

The last bug reported by @jayeshmangwani does look like a regression that we have to address before we can merge this PR.

the reason for this behaiour is that in the hooks when we paste a text, we only have access to the pasted text and not the text already present in the composer

Can we pass the text already present in the composer as a param to the hook?

@jayeshmangwani

Copy link
Copy Markdown
Contributor

@kpadmanabhan @roryabraham Let's close/HOLD this PR. This proposal was selected for another issue, and that proposal will solve our original issue.

@kpadmanabhan

kpadmanabhan commented May 30, 2024 •

Copy link
Copy Markdown
Author

Right now, in the main branch in composer, when we copy the multi newline and paste it between the large message, then new lines don't lose the originally copied newlines; and now, after adding the above changes in this PR, when we copy the muli new lines text between the large message then leading and trailing newlines got removed, below I am adding two videos for the visual effect of the changes between main and this PR cc: @roryabraham

@jayeshmangwani / @roryabraham : i have fixed the issue you reported by checking for existing hooks
however, if there is a newline at the end in the composer, while pasting text into the composer, I see errors in console and am fixing that. I think as #42216 (comment) has not created a PR until now, it is better to go with this current PR.

@jayeshmangwani

Copy link
Copy Markdown
Contributor

I think as #42216 (comment) has not created a PR until now, it is better to go with this current PR.

Technically, we should go with existing PR as this is already in motion, but our changes of replacing the new lines (CR LF) are causing a regression, and the solution on the other issue looks good and does not cause any known regression, so I do think we should go with the other proposal

@kpadmanabhan

Copy link
Copy Markdown
Author

@jayeshmangwani / @roryabraham : kindly suggest whether I should continue with this PR or put it on hold until other PR is deployed. In which case what will happen to the effort and time spent on this PR?

@kpadmanabhan

Copy link
Copy Markdown
Author

@jayeshmangwani / @roryabraham : kindly suggest whether I should continue with this PR or put it on hold until other PR is deployed. In which case what will happen to the effort and time spent on this PR?

@jayeshmangwani / @roryabraham : how should I continue with this? kindly recommend.

@jayeshmangwani

Copy link
Copy Markdown
Contributor

kindly suggest whether I should continue with this PR or put it on hold until other PR is deployed

@kpadmanabhan HOLD this PR please, our original proposed changes will cause the regression and other PR is close to getting merged

In which case what will happen to the effort and time spent on this PR?

I will raise this internally and will post here once I get the update

cc: @roryabraham

@kpadmanabhan kpadmanabhan changed the title trim leading and trailing CR LF during paste into composer [HOLD for PR #42892] trim leading and trailing CR LF during paste into composer Jun 6, 2024
@jayeshmangwani

Copy link
Copy Markdown
Contributor

@kpadmanabhan It looks like the issue has been fixed now. I am no longer able to reproduce it. Can you please verify?

@kpadmanabhan

Copy link
Copy Markdown
Author

@kpadmanabhan It looks like the issue has been fixed now. I am no longer able to reproduce it. Can you please verify?

@jayeshmangwani :
#42892 (comment)

@jayeshmangwani

Copy link
Copy Markdown
Contributor

@kpadmanabhan Please close this PR

@kpadmanabhan

Copy link
Copy Markdown
Author

@kpadmanabhan Please close this PR

This issue is not reproducible in main HEAD anymore. Closing this PR.

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.

3 participants