Skip to content

Fix cursor position problems on mWeb #700

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Skalakid
Copy link
Collaborator

@Skalakid Skalakid commented Jun 11, 2025

Details

This PR fixes issues with invalid cursor position on Android mWeb in cases when multiline markdown syntax is being removed. The problem lay in the current Live Markdown Input structure, where after splitting text into lines, we were merging all lines that contained ranges that go beyond the line length into one line. Now, if the markdown type isn't marked as a multiline type (the one that can have <br> tags in it), we are corresponding ranges into separate lines.

chrome.mWeb.mov

Related Issues

Expensify/App#57024

Manual Tests

Linked PRs

@Skalakid Skalakid changed the title Reposition keyup event selection changes Fix cursor position problems on native devices Jun 16, 2025
@Skalakid Skalakid changed the title Fix cursor position problems on native devices Fix cursor position problems on mWeb Jun 16, 2025
@Skalakid Skalakid marked this pull request as ready for review June 17, 2025 11:25
Copy link
Contributor

@jmusial jmusial left a comment

Choose a reason for hiding this comment

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

Fix works great!
Added just 2 improvement suggestions

function mergeLinesWithMultilineTags(lines: Paragraph[], ranges: MarkdownRange[]) {
/**
* For singleline markdown types, the function splits markdown ranges that spread beyond the line length into separate lines.
* For multiline markdown types (like `pre`), it merges them and corresponsing text into one line.
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
* For multiline markdown types (like `pre`), it merges them and corresponsing text into one line.
* For multiline markdown types (like `pre`), it merges them and corresponding text into one line.

* For singleline markdown types, the function splits markdown ranges that spread beyond the line length into separate lines.
* For multiline markdown types (like `pre`), it merges them and corresponsing text into one line.
*/
function normalizeLines(lines: Paragraph[], ranges: MarkdownRange[]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this function has grown quite a bit :(
Maybe it can be refactored, so each case is a named function?

* For singleline markdown types, the function splits markdown ranges that spread beyond the line length into separate lines.
* For multiline markdown types (like `pre`), it merges them and corresponsing text into one line.
*/
function normalizeLines(lines: Paragraph[], ranges: MarkdownRange[]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would love some tests for this as well :D

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.

2 participants