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
Support editor functions after reattach to DOM #4481
Conversation
@ckeditor/qa-team Could you please look at this? Also, after recreation the edit area: random functions may fail, like selection etc. For sure: any IE will fail (including 11) - so there is no need to verify this browser for now. Edge should be fine. Please ask me anything if some more explanation is needed. |
I go through many issues related to Without an opened console, it should work also on IE. |
On Safari toggling the editor in some cases removes content and makes the editor unfocusable. Steps to reproduce:Scenario 1:
CKE4_detached_safari_scenario1.mp4Scenario 2:
CKE4_detached_safari_scenario2.mp4Scenario 3:
CKE4_detached_safari_scenario3.mp4Result:The content of the editor is missing and the editor is unfocusable. Toggling the editor once again or toggling source mode is fixing the issue.
|
Rebase onto newest major. |
There still some weird things happening on Safari. Redoing steps from my previous comment results in blinking content and high CPU usage: CKE4-detached_safari_4462-1.mp4Edit: This behavior was caused by some cache in the browser. I've tested this case on a few different devices and everything is working correctly. |
@LukaszGudel - thank you. This is something I just can't catch on BrowserStack... |
I've retested this feature on all browsers and everything seems to work correctly 👍 |
CI - green, QA -verified on various browsers, so do I. |
It's been a while since we last heard from you. We are marking this pull request as stale due to inactivity. Please provide the requested feedback or the pull request will be closed after next 7 days. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Editor can be detached and reattached with the same content, also undo steps are preserved, also integrations with Angular, React and Vue still work, so 👍🏻 Especially that the fix doesn't look very obvious.
OTOH, in manual test if I detach editor and then click setData()
button, I've got an error. So I'm wondering - is this expected (if yes then we should rename this issue to indicate that editor can be detached and reattached, but not suggest that it works when detached) or not (and we still have to fix it). I guess either of you @sculpt0r and @f1ames can specify this as you together decided to extract #4462 so please clarify what is the goal of this issue.
Did you encounter some issues trying to write unit tests? I think they would be useful here to easily check some cases with executing commands (TBH manual test could also be automated, but it is also useful as is since you can control more things about editor's behaviour).
As for the manual tests, I'd like to have another one checking if undo steps are preserved (they are now so 👍🏻 ). So the steps would be something like:
- Type anything.
- Change formatting.
- Detach.
- Reattach.
- Check if there are two undo steps and you can go back to the beginning.
Besides that - please take a look at inline comments.
That's something we know about. Truth is, the original issue should be called: |
@Dumluregn - CI is still green - so ready for another review :) |
Yeah, I can imagine the amount of work to fix all issues with selection etc., so it makes sense 👍 @sculpt0r could you please also refer to this part of my comment:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code needs only a little bit of polish, good job 👍🏻 We could use some more testing though.
As for the unit tests, we already talked and agreed that we want to have at least the basic scenarios covered.
As for the manuals, as I've mentioned at the end of the previous review, we need another test for undo
and perhaps some other core integrations (like elementspath
, formatting, links etc.). Besides that, we need to cover also other editor types (divarea
and inline
). I've briefly tested them and they seem to work, but still separate tests for each of them is a must (just copy detached
test and change editor type - don't add more editors there as it already has a long test description). And also a test with two editors where we reattach one of them to check if the correct data is bound to it.
So to sum up, we want to have the following manual tests:
- General test for reattaching and preserving data - already covered in
detached
👍🏻 - Same test as 1 for divarea editor.
- Same test as 1 for inline editor.
- Test for
undo
integration with classic editor. - Test for two editors in the same page and reattaching one of them.
- Open test (kind of monkey clicking) for the integration of at least part of the editor features.
If you think that some of those scenarios would be a good fit for a unit test instead, feel free to propose it.
Added requested changes:
I added an automatic test for the detached
|
It looks strange before, because if shouldRecreate we actually return...
Those break querySelector in IE
Rebased onto latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sculpt0r I hate to say it but... we still have work to do here...
I tried to reproduce the errors mentioned by @LukaszGudel and I didn't, but found more two issues during the monkey clicking.
Scenario 1)
- Embed an image (using dialog or autoembed).
- Toggle source mode twice.
The whole webpage freezes. And as this happens even without detaching the editor, we have to fix it.
Scenario 2)
- Insert image to editor.
- Detach and reattach editor.
This creates one dummy undo step which doesn't change the content. I would say it isn't something critical and only happens after toggling the editor, so if the fix would take more than 1/2 MD then let's extract this as a separate issue.
PS I've pushed some changes so remember to pull the latest branch.
Looks like This ckeditor4/core/htmlparser/fragment.js Line 107 in 05e2b11
else ckeditor4/core/htmlparser/fragment.js Line 131 in 05e2b11
The hardest part: why adding onload to iframe causes crash here 🗡️
ckeditor4/core/htmlparser/fragment.js Line 93 in 05e2b11
root.name is body . With this fix, root.name is textarea Funny thing, there is no error if I try to use a debugger - which leads me to time-related issues... Additional |
It's been a while since we last heard from you. We are marking this pull request as stale due to inactivity. Please provide the requested feedback or the pull request will be closed after next 7 days. |
Closing due to:
This solution works in IE < 11, but was error-prone (due to relying on |
What is the purpose of this pull request?
New feature
Does your PR contain necessary tests?
All patches that change the editor code must include tests. You can always read more
on PR testing,
how to set the testing environment and
how to create tests
in the official CKEditor documentation.
This PR contains
Did you follow the CKEditor 4 code style guide?
Your code should follow the guidelines from the CKEditor 4 code style guide which helps keep the entire codebase consistent.
What is the proposed changelog entry for this pull request?
What changes did you make?
Give an overview…
Which issues does your PR resolve?
Closes #4462 .