Closed woaiiimipi closed 2 months ago
Simplest reproduction (with GHS enabled):
<ul class="todo-list">
<li>
<label class="todo-list__label todo-list__label_without-description"><input type="checkbox" checked="checked" disabled="disabled"></label>
<p class="foo">
foobar
</p>
</li>
</ul>
Also reproducible when changing the alignment on an item in a todo list. Steps to repro:
editor.setData(editor.getData())
It seems that the checked="checked"
attribute goes missing when the text inside the <li>
gets wrapped in an additional element, e.g. <p>
.
Any update? Our clients report this issue again, I think it's an very important function.
@niegowski @Witoso @mabryl Is there any way to avoid it? Too many of our users have encountered this problem.
As I see it doesn't work with p
element, while with span
everything works fine (GHS is not required to check it):
<ul class="todo-list">
<li>
<label class="todo-list__label todo-list__label_without-description"><input type="checkbox" checked="checked" disabled="disabled"></label>
<span class="foo">
foobar
</span>
</li>
</ul>
So conversion treats todo list with p
element a little bit differently.
This method override data.modelCursor
: https://github.com/ckeditor/ckeditor5/blob/28d0389424dcb74d1163741d33a379e26816fc4c/packages/ckeditor5-engine/src/conversion/upcastdispatcher.ts#L351-L379
Inside modelCursor
we could find an array with 3 elements (first and third elements are empty so they will be removed but they have actual attribute which is responsible for checked
property while second doesn't have that attribute but have the text node)
First element:
Second element:
Third element:
Meanwhile todo list item with span
element have only 1 (with text and attributes), not 3:
Here is a method which remove empty elements (so only second element with text data from the array is left but it doesn't have todo-list-checked
attribute) so that the reason of data lost: https://github.com/ckeditor/ckeditor5/blob/28d0389424dcb74d1163741d33a379e26816fc4c/packages/ckeditor5-engine/src/conversion/upcastdispatcher.ts#L500-L516
Here is example solution: https://github.com/ckeditor/ckeditor5/pull/16785
📝 Provide detailed reproduction steps (if any)
When I add todolist to a table cell, I checked the checkbox, and saved the data to server, when I reload the data, the checkbox's checked status is lost.
Before:
Reload:
Below is my source code, you can copy the code to source editing, the checked="checked" status will be lost
✔️ Expected result
Checked status can reload correctly
❌ Actual result
Checked status is lost.
❓ Possible solution
📃 Other details
If you'd like to see this fixed sooner, add a 👍 reaction to this post.