Closed Skalakid closed 1 month ago
Firefox: Cursor positioning on focus
It's not a bug. It happens because in App.tsx
we are passing the selection prop with index 0. The same happens on main right now. If you delete the prop, everything works fine and the cursor is positioned at the end of the text
Firefox: Weird spellcheck (different than on Chrome)
I think it depends on your default keyboard language. I'm not sure if we can change anything in this case since is browser-native functionality. On my side, it looks like this:
@BartoszGrajdek I just fixed all reported bugs 🫡
Not sure how far along we are with this but wanted to ping about https://github.com/Expensify/App/issues/45345 - looks like something we might be able to fix here!
@dangrous The Refactor PR is still in progress and now we are focused on fixing bugs reported by the QA team in https://github.com/Expensify/App/pull/45150. This refactor fixes the issue you linked, however, it will take some time until we merge this into E/App. If you need the fix quicker we can do it in a separate PR. What's your opinion?
EDIT: I can't reproduce this issue, https://github.com/Expensify/App/pull/44958 might have fixed it
oh nice! I don't think this is high priority, so we can wait (unless https://github.com/Expensify/App/pull/44958 fixed it!)
I've been trying to fix this Android web issue (you can see some of my takeaways in the comments). It led me to parseText
method in parserUtils.ts, more specifically these lines:
if (!rootSpan || rootSpan.innerHTML !== dom.innerHTML) {
targetElement.innerHTML = '';
targetElement.innerText = '';
target.appendChild(dom);
if (BrowserUtils.isChromium) {
moveCursor(isFocused, alwaysMoveCursorToTheEnd, cursorPosition, target);
}
}
I also contacted @BartoszGrajdek (shout out to him) to discuss it and he suggested to give this PR a try, as it refactors the web implementation. Here is what I discovered on both web and Android web:
(I had to remove TEST_CONST.EXAMPLE_CONTENT
as the bug that I'm trying to fix only occurs for an empty input)
Case 1
- const [value, setValue] = React.useState(TEST_CONST.EXAMPLE_CONTENT);
+ const [value, setValue] = React.useState();
Voice recognition works, markdown doesn't work
Case 2
- const [value, setValue] = React.useState(TEST_CONST.EXAMPLE_CONTENT);
+ const [value, setValue] = React.useState('');
Voice recognition doesn't work, markdown works
To test the voice recognition, I started from an empty input and dictated a sentence, to test markdown I simply typed bold or something similar.
Details
This PR refactors the web implementation of the Live Markdown library. The main goals of it are:
During this refactor phase we:
changed web live markdown HTML structure so now:
<p>
- it makes structure much clear and organized, and enables us to apply custom logic to specific lines<span data-type="text">
tag - by wrapping text with HTML element we enable many useful functions that aren't available in normal text node, for example:scrollIntoView()
\n
characters inside the input's HTML structure we use<br>
tags - br tags give use much more flexibility and fix problem with cursor navigation when using arrow keys when moving between markdown components<br>
tag is wrapped with<span data-type="br">
tag - it fixes many problems connected to cursor positioningThanks to the new structure we enabled the usage of many styles that were generating a lot of bugs in the past, like
display: block
. Also were able to remove all workarounds connected to cursor positioning.added HTML tree node structure, that represents current HTML dom and stores many important information about every element inside the input. Thanks to this tree structure we can easily interact with the markdown elements and we were able to completely refactor and improve the performance of cursor positioning algorithms
replaced all text value representation functions like
process value
ornormalizeValue
with onetextContent
variable that always contains properly formatted text value without any additional newlines from contentEditablesplit long files of code into smaller ones, and sort functions into utils
prepared the code for new, more complex features like inline images
This refactor was made as a part of inline image feature. After discovering some structure and logic limitations when creating inline image POC we decided to improve Live Markdown for web.
This refactor will fix or unblock following issues:
Related Issues
GH_LINK
Manual Tests
Since it's a big change it would be great to test it in all cases connected to:
Linked PRs
https://github.com/Expensify/App/issues/40181#issuecomment-2180897156