-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
refactor: replace insertText from #6553 changes to reflect new removeText feature #6744
base: main
Are you sure you want to change the base?
Conversation
…w removeText changes
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
Its funny now, coz it passes all the tests here, but fails those two issues locally... |
This is great! Thanks for continuing this ❤️ |
As a new contributor, for security reasons, GitHub doesn't automatically run the CI tests before a reviewer clicks a button. It'll probably fail when they are run. |
mehnn, was this tuff... rewrote the inserText functions so many times ( i do have four implemenatations of it lol ), before i could come close to figuring out the issue.
|
ideally for that condition where there is pre existing content in the node, the offset should be the length of the new text we want to insert not the lenght of both.. // packages/lexical-selection/src/tests/unit/LexicalSelectionHelpers.test.ts line 152 expect($getNodeByKey('a')!.getTextContent()).toBe('Testa'); the test fails
|
i could add this after setting new content,
which should work, but i think because its stuck inside the loop, so it just defaults the offset of the anchor and focus.... @GermanJablo @etrepum what do you suggest i do? |
I think in this scenario you also need to consider cases where anchor.offset !== focus.offset, we know that anchor.offset === 0 but we don't know what focus.offset is, so it should probably be this:
I'm sure there are other problems though, because focus.offset isn't even considered and I don't see how the selection will be updated correctly in the cases where setTextContent is called |
@etrepum @GermanJablo think it's good to go |
i didnt even realise there were e2e tests... wow , i wonder how I will debug this thing and proceed 😅 |
ok, looking at the older 'insertText' implementation.... the refactored one I am working on(although passes the core tests but fails some e2e tests)...there are some missing features like
I will try to add them features and try again 👍 |
In the draft version I commented on at the time, only about 5 tests failed, considering both unit tests and e2e, so it shouldn't require any major changes. You are calling The selection module is very complex, so this is not an easy task. |
@GermanJablo hmmm, i understand. I have been doing it all wrong(or taking a wrong apprach) I did not pay attention to the But as you said, the removeText might need some modification to pass both tests... Thanks |
I am having some problems moving forward in the pr, would love a review to point me in the right direction. Im a little blocked ... @GermanJablo @etrepum |
I think the first step would be to follow @GermanJablo's suggestion and make the removeText unconditional, without going deep into the code and seeing which tests that affects it would be hard to provide any more direction |
This PR aims to Refactor #6553 : simplified insertText rewrite (part 2)
Right now, without changing the commented code that uses the new removeText feature. It passes almost all the tests except
2 cases
I will be investigating why this is the issue and as @GermanJablo said, i will make some refinements to his draft
insertText
to fix those errors