fix(core): correctly reset PTE list counts after non-numbered lists and in sublists #7506
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
I find that the numbered list is incorrectly indexed in two places.
Case 1: On Sub-list items
The indices of list items starting at
level 2
tolevel 9
do not start over even though they are separate lists. Instead, they continue on the counter from the previous list. This is already mentioned at #6879.Before
After
Case 2: Created right after a bullet list
If a numbered list is created right after a bullet list, the indices continue from the previous list counter. It is caused by using the
counter-reset
instead ofcounter-set
, making the reset step ineffective.Before
After
What to review
Overall, the counter is initialized under the
.pt-editable
element and will be reset to0
at every element that is not a numbered list item. In addition, the counter increases by1
at each numbered list item until the list ends. On the other hand, it resets the counter for elements not part of the numbered list.In order to fix Case 1, I removed the code on
line:98
and let the rule set for non-numbered list items take effect on bullet list items as well.In order to fix Case 2, I decided to target the
level 1
list item and reset the counter all levels between2 - 9
.Testing
I test it manually by creating various lists which have multi-level nested items. In addition, I intend to add more different block elements between the lists to ensure the counter is correct.
Notes for release