-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
[$250] Markdown - Cursor position moves to start when inserting a new break in a hyperlink #43922
Comments
Triggered auto assignment to @sakluger ( |
@sakluger 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 |
We think that this bug might be related to #vip-vsp |
Job added to Upwork: https://www.upwork.com/jobs/~019e1861b7a8f9e8fd |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ikevin127 ( |
ProposalPlease re-state the problem that we are trying to solve in this issue.Cursor position moves to start when inserting a new break in a hyperlink What is the root cause of that problem?When the user inputs a newline character at the end of a Markdown string, it disappears after parsing. Therefore, when comparing conditions, this discrepancy can lead to incorrect evaluations What changes do you think we should make in order to solve the problem?Trim the Markdown input prior to condition checks to mitigate whitespace discrepancies. In parseExpensiMarkToRanges at parser, should add .trim() like in the code snippet below: function parseExpensiMarkToRanges(markdown: string): Range[] {
try {
const html = parseMarkdownToHTML(markdown);
const tokens = parseHTMLToTokens(html);
const tree = parseTokensToTree(tokens);
const [text, ranges] = parseTreeToTextAndRanges(tree);
- if (text !== markdown) {
+ if (text !== markdown.trim()) { POCScreen.Recording.2024-06-19.at.04.06.39.movWhat alternative solutions did you explore? (Optional) |
@huult Thanks for your proposal. A few clarifications before I can reach a point where I can verify your proposal:
Note: I applied the suggested changes in the react-native-live-markdown repo, compiled and used the compiled Here's a console log of the variables after implementing the solution:![]() Given these results, it would make sense that the error is still thrown from that if condition. So I'm curious if you left out a certain part of the solution from your proposal or if not - how come the issue is fixed on your side ? 🤔 Note: Looks like the difference between original / processed input is |
ProposalPlease re-state the problem that we are trying to solve in this issue.Cursor move to beginning when insert trailing What is the root cause of that problem?There are two errors thrown out actually. The first error can somehow trigger this condition What changes do you think we should make in order to solve the problem?Fix the first error
to
Similar change apply to this line Fix the second error What alternative solutions did you explore? (Optional)N/A |
ProposalPlease re-state the problem that we are trying to solve in this issue.Cursor position moves to start when inserting a new break in a hyperlink What is the root cause of that problem?We set cursor to the front of text in setCursorPosition at react-native-live-markdown-parser: here What changes do you think we should make in order to solve the problem?I got stable and successful results changed the first "if" statement conditions to: if (nextChar !== '\n' && textNodes.length > 1) {
range.setStart(textNodes[i], 0);
} |
@Amoralchik Hi, gently remind, your suggesting code change is trying to fix the second error mentioned in my proposal, which is a duplication of this. And I personally do not recommend change |
Hi @ikevin127 , Firstly, I would like to thank you for reviewing my proposal. When the user wants to enter a line where the value is text, a newline character (\n) is added to the value. This value is then sent to the parseExpensiMarkToRanges function of react-native-live-markdown. Like the image below: ![]() So I trimmed the markdown to remove \n from it, but that was incorrect. Accidentally, this issue was resolved because the selection did not reset to {start: 0, end: 0} Thanks, |
🙏 Thanks everybody for your interest in fixing this issue! Currently @Amoralchik's solution is the only one that fixes the issue. Performing the action still throws the match related error (for obvious reasons), but the cursor position is not being reset anymore -> which fulfils our issue's expected result: Screen.Recording.2024-06-19.at.18.51.58.movWhat's Next ?Regarding the proposed solution: - if (nextChar !== '\n') {
+ if (nextChar !== '\n' && textNodes.length > 1) {
range.setStart(textNodes[i], 0);
} I'm afraid that the change might cause regressions even though all |
@ikevin127 Hi, have you checked my proposal? |
Yes, I did check all proposals and the issue was still reproducible in all of them except Amoralchik's. Keep in mind that we're not looking to get rid of the first error since:
|
Then the second error has same root cause of this issue: #43239, and I do posted my proposal there, and have linked it in my proposal for this issue. |
Different issues, (slightly) different solutions. Additionally mallenexpensify notified you in the other issue to:
So don't worry, I also tagged BartoszGrajdek in #43922 (comment) for this issue and I mentioned that:
Whenever we get feedback, if they think that the other issue's solution would fix this one as well -> then nobody will get hired for this one, otherwise they might decide that we want to fix them separately. |
@ikevin127 Code changes in my proposal actually can fix this issue. Fix the first error indeed lead the second error disappears for this issue. I kind don't agree that:
To confirm code changes in my proposal can fix this issue:
@ikevin127 Maybe you don't replace all |
Hi! Thank you for tagging me here 🙌🏻 So I've looked through quite a few issues in recent days. I think this one is related to:
What @badeggg solution is trying to fix is actually the 1st issue linked. I agree that this is something we should aim to resolve, but I'm not sure if it's the best way to do it. This is a matter of preference that I would rather discuss with the Expensify Team. IMO there are 3 solutions to this problem:
What I'm going to do next is talk with the Next, we'll discuss it with the Expensify team to have a clear picture of how we want it to behave. 🔜 I'll keep you guys updated 🙏🏻 |
@BartoszGrajdek Hi, about the 3rd solution:
Be cautious, links that have leading or trailing spaces are causing same error, we can not recover to original comment text from parsed html after trimming. |
No, it doesn't fix our issue.
Yes, I did. Not sure if your solution works on any of the other issues, the only thing that I'm certain of is that it's not fixing this issue. Checkout the video below where I'm demonstrating applying your solution and the result proving that it doesn't change / fix our issue (cursor position reset), nor the match related error which you stated that your solution will fix even though I stated in #43922 (comment) that:
which you said you disagree with, without actually providing any reasoning as to why 🤔 Getting back to your solution
Note: I did this from E/App Watch videoScreen.Recording.2024-06-20.at.13.mp4cc @badeggg ConclusionRegardless of your solution working or not for this issue (which it doesn't, as proven above), I would still have massive reservations in selecting it simply because those 2 The reason why I'm leaning towards Amoralchik's solution is because:
Even if we decide to proceed with their solution, I still have some reservations when it comes to the change potentially causing regressions as mentioned in #43922 (comment), reason for which I decided to include BartoszGrajdek in the discussion for this issue as well since they are part of the team which created and maintain the |
@ikevin127 The video you provided, from 42sec to 48sec, that's not the change I suggested. My suggested change is only delete two To change |
About this:
I believe the error trigger path is this:
Trigger path is linear. You can't say the first error is not the root cause. |
Just in case, I have to say, file |
I know this, I will amend my previous comment if adding one more comment is disturbing others.
I thought you know react-native-live-markdown relying on expensify-common. My mistake.
If you say so. Just try to clarify that code changes in my proposal can work. 🤝 |
I've temporarily removed the |
Wouldn't call it disturbing but it's good to know that most of us that are participating to this issue (7 currently) are getting notified everytime somebody posts a new comment - you posted 3 in a row and that's why I mentioned the alternative 👍
You are forgiven! For your convenience, here are some of the raw proposal template recommendations: For Contributors
For Reviewers
I want to highlight that it's paramount, if you want your proposals to be considered, that you are very specific with both the root cause of the issue, the proposed solution and where / how should this solution be implemented because:
Here's an example of regression your proposed solution will cause by removing only one
Again, regardless of whether your solution Tip
cc @badeggg |
Hello everyone! 👋🏻 A couple of things have changed since I last updated you here. Let me go through them one by one: Should we support multiline links?
I've spoken to the SWM team, and according to my colleagues, we already had a brief discussion about it earlier. The Expensify Team was leaning towards handling multiline links, so I don't think that's something we should be changing right now. Cursor positioning problemThis has been fixed. If you go onto staging the cursor should be positioned correctly when creating a multiline link. That's due to this PR, which is patching Unfortunately, this still doesn't fix our markdown / ExpensiMark problem. Multiline link markdownThere are currently 2 issues that are related to problems with multiline hyperlinks. This one and one of the issues I've linked previously. Both of them are different but could conflict with one another in terms of solutions, so I'll let you decide if we want to keep both of them or maybe merge them @ikevin127 🙌🏻 As for fixing multiline hyperlink problems with
I will try to research that problem a bit, with a more holistic approach, maybe inside |
Thank you for the detailed breakdown BartoszGrajdek, will get back on this soon! |
@thienlnam this is also an issue related to live markdown, could we add it to the project? 🙏🏻 |
@sakluger, @ikevin127 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues! |
@sakluger I can confirm that this issue is not reproducible anymore: VideoScreen.Recording.2024-06-28.at.12.21.14.movScreen.Recording.2024-06-28.at.12.21.14.movGiven that this issue's expected result was fulfilled (IMO), I think the other Note: I think this can be closed as fixed if no objections are raised.
As mentioned above, I think we should keep them separate as this one was already fixed while the other one is still reproducible. This being said, I'd be good to keep this one in mind when testing the fix for the other one to make sure the regression (this issue) is not reintroduced. |
Hey @ikevin127, thanks so much for retesting and confirming that it's no longer reproducible. I agree that we can close out this issue. Thanks everyone! |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Version Number: 1.4.85-0
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/4641558
Issue reported by: Applause - Internal Team
Action Performed:
Expected Result:
The cursor positions itself in the beginning of the new line
Actual Result:
The cursor positions itself in the beginning of the first line
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
Bug6517276_1718718866342.bandicam_2024-06-18_16-47-50-581.mp4
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @ikevin127The text was updated successfully, but these errors were encountered: