Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.53k stars 2.88k forks source link

[$250] Chat - Cursor moves several characters when deleting markdowns on multiline message #50687

Open IuliiaHerets opened 3 weeks ago

IuliiaHerets commented 3 weeks ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.0.48-0 Reproducible in staging?: Y Issue reported by: Applause Internal Team

Action Performed:

  1. Open the staging.new.expensify.com website.
  2. Open any chat.
  3. Write a multiline message with at least five line breaks and three markdowns and send it.
  4. Long tap over the sent message.
  5. Tap on "Edit Message"
  6. Delete the markdowns at the end of the message.
  7. Verify the cursor moves only one character everytime a markdown is deleted.

Expected Result:

The cursor should move only one character at the time while deleting markdowns at the end of a message.

Actual Result:

When deleting the markdowns at the end of a multiline message while editing, the cursor moves several characters at the time.

Workaround:

Unknown

Platforms:

Screenshots/Videos

https://github.com/user-attachments/assets/1648cb08-1348-4926-a0a0-a03fc2650018

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021847007161571207373
  • Upwork Job ID: 1847007161571207373
  • Last Price Increase: 2024-11-07
Issue OwnerCurrent Issue Owner: @thesahindia
melvin-bot[bot] commented 3 weeks ago

Triggered auto assignment to @OfstadC (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.

IuliiaHerets commented 3 weeks ago

We think that this bug might be related to #wave-collect - Release 1

IuliiaHerets commented 3 weeks ago

@OfstadC 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

shahinyan11 commented 3 weeks ago

Edited by proposal-police: This proposal was edited at 2024-10-31 09:57:22 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

Chat - Cursor moves several characters when deleting markdowns on multiline message

What is the root cause of that problem?

The problem comes from react-native-live-markdown package. The package has custom cursor management logic and those works well. The issue occurs because the custom cursor management logic runs faster than React’s native text update. As a result, the cursor is repositioned too early. When React completes its slower text update, it overwrites the manually set cursor position, causing it to be incorrect. This timing mismatch leads to the cursor jumping to the wrong place.

What changes do you think we should make in order to solve the problem?

Wrapping this code in InteractionManager will solve the problem

InteractionManager.runAfterInteractions(()=> {
  if (shouldForceDOMUpdate || targetElement.innerHTML !== dom.innerHTML) {
    const animationTimes = getAnimationCurrentTimes(targetElement);
    targetElement.innerHTML = '';
    targetElement.innerText = '';
    targetElement.innerHTML = dom.innerHTML;
    updateAnimationsTime(targetElement, animationTimes);
  }
  updateTreeElementRefs(tree, targetElement);
  targetElement.tree = tree;

  moveCursor(isFocused, alwaysMoveCursorToTheEnd, cursorPosition, targetElement, shouldScrollIntoView);
})

What alternative solutions did you explore? (Optional)

We can wrap this code in an InteractionManager instead above one, but that will cause the cursor to jump up and down.

OfstadC commented 3 weeks ago

I did not experience this. I also think this is kind of an odd scenario that is unlikely to occur for a user (must have 5 line breaks and 3 markdowns seems like an odd equation ) - So going to close this out

shahinyan11 commented 3 weeks ago

@OfstadC The bug is actual now, and it happens even with 1 or 2 line breaks. I am Sorry but I think you should retest

https://github.com/user-attachments/assets/b49e791c-da17-4ff4-b9ea-8d1b5b997849

melvin-bot[bot] commented 3 weeks ago

Job added to Upwork: https://www.upwork.com/jobs/~021847007161571207373

melvin-bot[bot] commented 3 weeks ago

Triggered auto assignment to Contributor-plus team member for initial proposal review - @thesahindia (External)

melvin-bot[bot] commented 2 weeks ago

@OfstadC, @thesahindia Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

shahinyan11 commented 2 weeks ago

Hi @thesahindia. Did you notice my proposal above ?

OfstadC commented 2 weeks ago

@thesahindia could you please review the available proposal by EOD? Thank you 😃

thesahindia commented 2 weeks ago

I couldn't repro it. I tested on the latest dev version.

https://github.com/user-attachments/assets/d710a5e3-869d-429e-8668-0739574f6e95

shahinyan11 commented 2 weeks ago

@thesahindia It is reproducible in last main

https://github.com/user-attachments/assets/b3cb9521-b377-4082-a397-59a1a9b64ae8

melvin-bot[bot] commented 2 weeks ago

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

thesahindia commented 2 weeks ago

I still can't repro it. @OfstadC, could you please look into it?

shahinyan11 commented 2 weeks ago

I still can't repro it. @OfstadC, could you please look into it?

@thesahindia Have you tested android mWeb ?

melvin-bot[bot] commented 1 week ago

@OfstadC @thesahindia this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

thesahindia commented 1 week ago

I was able to repro it on mWeb. @shahinyan11, could you repro it on native or is it just a mWeb issue?

shahinyan11 commented 1 week ago

I was able to repro it on mWeb. @shahinyan11, could you repro it on native or is it just a mWeb issue?

I could repro only on mWeb

melvin-bot[bot] commented 1 week ago

@OfstadC, @thesahindia Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

thesahindia commented 1 week ago

@shahinyan11, Could you retest your solution? Also could you please share the video of testing?

shahinyan11 commented 1 week ago

Proposal

Updated Since the package was updated, the previous solution stopped working and I updated the proposal.

shahinyan11 commented 1 week ago

@thesahindia Here is the video

https://github.com/user-attachments/assets/dd3fa50f-7647-4737-b5c1-752a1d97fb74

melvin-bot[bot] commented 1 week ago

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

thesahindia commented 1 week ago

I need to test some cases; I'll handle it on Monday since it's the weekend.

melvin-bot[bot] commented 3 days ago

@OfstadC, @thesahindia Whoops! This issue is 2 days overdue. Let's get this updated quick!

OfstadC commented 3 days ago

Any update @thesahindia 😃

melvin-bot[bot] commented 1 day ago

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

OfstadC commented 1 day ago

Bump @shahinyan11 Please update by EOD tomorrow 😃 Thanks!

shahinyan11 commented 20 hours ago

Bump @shahinyan11 Please update by EOD tomorrow 😃 ThankS!

Hi @OfstadC . I think you have mentioned me by mistake anD it should be addressed to @thesahindia . If not, please clarify what update you mean.