You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$250] Markdown - Space in the Code Block is removed after Manually copying and pasting #43331
Version Number: 1.4.80-16 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail:https://expensify.testrail.io/index.php?/tests/view/4606901 Email or phone of affected tester (no customers):dave0123seife+admin@gmail.com Issue reported by: Applause - Internal Team
Action Performed:
Navigate to a 1:1 chat
Send a message with a Code block. Make the code block a multiline with an extra line between the markdown and text.
Manually Copy and paste the message with the code block
Expected Result:
The correct markdown format is pasted
Actual Result:
The markdown format removes the line space
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
@MitchExpensify FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors
I have tested again after applied the solution from the PR #42892 and it doesn't solve the current issue, can you please link between this issue and other one how they are related ?
In main HEAD, copying using Copy to Clipboard menu item works fine with complete text from the code block. But using CTRL+C copies only the current text without the newline inside the code.
Recording.2024-06-14.011634.mp4
The fix for #39971 will not solve this issue. The text is already trimmed while copying to clipboard.
Working on this. Will update soon here.
From the initial video recording in bug description, the text is NOT selected in full. Only 1 trailing newline is selected by selecting the text. To select the complete code block, one will need to go till end of code block till end of message. The same is demonstrated in the video recording further below.
Send button is not enabled because the trailing CR LF (\n) while pasting is not considered in selection and hence not considered in the range length.
src\hooks\useHtmlPaste\index.ts
const insertAtCaret = (target: HTMLElement, text: string) => {
. . .
// Move caret to the end of the newly inserted text node.
range.setStart(node, node.length);
range.setEnd(node, node.length);
. . .
What changes do you think we should make in order to solve the problem?
Check if this is a code block or is text having trailing newline, then calculate range accordingly with offset.
src\hooks\useHtmlPaste\index.ts
const insertAtCaret = (target: HTMLElement, text: string) => {
. . .
// Move caret to the end of the newly inserted text node.
// Text with newline at end or code block that ends with ```
// These lines must be pasted in full and "Send" button enabled.
// length reduced by an offset of 1 character to accommodate the trailing \n (CR LF)
const offset = text.trimEnd().endsWith('```') || text.endsWith('\n')
? node.length - 1 : node.length;
range.setStart(node, offset);
range.setEnd(node, offset);
. . .
This makes sure that the correctly selected code block is pasted in full and send button is enabled.
In latest mainHEAD I still see these behaviour as explained and shown in my proposal.
Also pasting of text from "Copy to clipboard" context menu is ending up placing the cursor at end of code block. @eVoloshchak : the issue you mentioned is not reproducible at my side.
@adelekennedy : the core issue seems to be fixed. however there are regressions w.r.t copying using mouse / trackpad click and drag. if you do nmot click and drag till outside of the message (not just till outside code block), then this works fine in mainHEAD.
@eVoloshchak / @adelekennedy : shall i pick this up for fixing? key problem here is the selection of text from code block.
fix will be that in case selection is till end of message and the data from clipboardv endswith code block, then add extra newline if selected till end.
I'm not sure if this is worth fixing, it's not a bug with the app itself, but rather the way OS handles text selection.
I can observe the same behavior here on GitHub
Activity
melvin-bot commentedon Jun 8, 2024
Triggered auto assignment to @MitchExpensify (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.lanitochka17 commentedon Jun 8, 2024
@MitchExpensify FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors
lanitochka17 commentedon Jun 8, 2024
We think that this bug might be related to #vip-vsp
kpadmanabhan commentedon Jun 10, 2024
@lanitochka17 : this is related to #39971
This is on hold as PR for this is blocked due to another related issue.
Awaiting update.
CC: @jayeshmangwani / @roryabraham
jayeshmangwani commentedon Jun 10, 2024
@kpadmanabhan Are you sure this is related to #39971 ?
I have tested again after applied the solution from the PR #42892 and it doesn't solve the current issue, can you please link between this issue and other one how they are related ?
MitchExpensify commentedon Jun 11, 2024
Not overdue, ball is in @kpadmanabhan 's court
kpadmanabhan commentedon Jun 13, 2024
@MitchExpensify / @jayeshmangwani : sorry for late response. On it now.
In main HEAD, copying using
Copy to Clipboardmenu item works fine with complete text from the code block. But using CTRL+C copies only the current text without the newline inside the code.Recording.2024-06-14.011634.mp4
The fix for #39971 will not solve this issue. The text is already trimmed while copying to clipboard.
Working on this. Will update soon here.
kpadmanabhan commentedon Jun 14, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Pasted code block trimming trailing newline characters.
What is the root cause of that problem?
Two concerns from the initially reported problem.
From the initial video recording in bug description, the text is NOT selected in full. Only 1 trailing newline is selected by selecting the text. To select the complete code block, one will need to go till end of code block till end of message. The same is demonstrated in the video recording further below.
Send button is not enabled because the trailing CR LF (\n) while pasting is not considered in selection and hence not considered in the range length.
src\hooks\useHtmlPaste\index.tsWhat changes do you think we should make in order to solve the problem?
Check if this is a code block or is text having trailing newline, then calculate range accordingly with offset.
src\hooks\useHtmlPaste\index.tsThis makes sure that the correctly selected code block is pasted in full and send button is enabled.
Recording.2024-06-14.132257.mp4
Recording.2024-06-14.133756.mp4
What alternative solutions did you explore? (Optional)
N.A.
kpadmanabhan commentedon Jun 14, 2024
@MitchExpensify / @jayeshmangwani / @lanitochka17 : if you think this solves the issue reported, please mark this bug external and kindly assign.
60 remaining items
melvin-bot commentedon Jul 22, 2024
@eVoloshchak, @adelekennedy Whoops! This issue is 2 days overdue. Let's get this updated quick!
adelekennedy commentedon Jul 23, 2024
@eVoloshchak what are the next steps here?
melvin-bot commentedon Jul 26, 2024
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
kpadmanabhan commentedon Jul 27, 2024
In latest
mainHEADI still see these behaviour as explained and shown in my proposal.Also pasting of text from "Copy to clipboard" context menu is ending up placing the cursor at end of code block.
@eVoloshchak : the issue you mentioned is not reproducible at my side.
@adelekennedy : the core issue seems to be fixed. however there are regressions w.r.t copying using mouse / trackpad click and drag. if you do nmot click and drag till outside of the message (not just till outside code block), then this works fine in
mainHEAD.Please let me know if you need further details.
melvin-bot commentedon Jul 29, 2024
@eVoloshchak, @adelekennedy Huh... This is 4 days overdue. Who can take care of this?
kpadmanabhan commentedon Jul 30, 2024
@eVoloshchak / @adelekennedy : shall i pick this up for fixing? key problem here is the selection of text from code block.
fix will be that in case selection is till end of message and the data from clipboardv endswith code block, then add extra newline if selected till end.
please suggest if i may proceed with the fix.
mallenexpensify commentedon Jul 30, 2024
@eVoloshchak 👀 above plz
melvin-bot commentedon Jul 31, 2024
@eVoloshchak, @adelekennedy 6 days overdue. This is scarier than being forced to listen to Vogon poetry!
eVoloshchak commentedon Aug 1, 2024
I'm not sure if this is worth fixing, it's not a bug with the app itself, but rather the way OS handles text selection.
I can observe the same behavior here on GitHub
Screen.Recording.2024-08-01.at.18.42.32.mov
@mallenexpensify, @adelekennedy, what are your thoughts?
adelekennedy commentedon Aug 1, 2024
I'd move to close it in that case, it's low priority any way