Skip to content
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

Fix for: Sublist order is reversed when higher level list is removed #2738

Merged
merged 10 commits into from
Jan 28, 2019
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

## CKEditor 4.11.3

Fixed Issues:

* [#2721](https://github.com/ckeditor/ckeditor-dev/issues/2721): Fixed: Sublist items are reversed when higher level list item is removed.

## CKEditor 4.11.2

Fixed Issues:
Expand Down
1 change: 1 addition & 0 deletions plugins/list/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@
child.remove();

refNode ? child[ forward ? 'insertBefore' : 'insertAfter' ]( refNode ) : into.append( child, forward );
refNode = child;
}
}

Expand Down
13 changes: 13 additions & 0 deletions tests/plugins/list/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,18 @@ bender.test( {
bot.setHtmlWithSelection( '<ul><li><table><tr><td>^foo</td></tr></table></li></ul>' );
var bList = ed.getCommand( 'bulletedlist' );
assert.areSame( CKEDITOR.TRISTATE_OFF, bList.state, 'check numbered list inactive' );
},

// #2721
'test sublist order after removing higher order sublist': function() {
var bot = this.editorBots.editor1,
editor = bot.editor;

bot.setHtmlWithSelection( '<ol><li>test<ol><li>^<ol><li>a</li><li>b</li><li>c</li></ol></li></ol></li></ol>' );
editor.fire( 'key', {
domEvent: new CKEDITOR.dom.event( { keyCode: 8 } )
} );

assert.areSame( '<ol><li>test<ol><li>a</li><li>b</li><li>c</li></ol></li></ol>', bender.tools.compatHtml( editor.getData() ) );
}
} );
23 changes: 23 additions & 0 deletions tests/plugins/list/manual/sublistreverse.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<textarea id="editor">
<ol>
<li>test
<ol>
<li>$
<ol>
<li>a</li>
<li>b</li>
<li>c</li>
</ol>
</li>
</ol>
</li>
</ol>
</textarea>

<script>
// Ignore until #2737 is resolved.
if ( CKEDITOR.env.edge ) {
bender.ignore();
}
CKEDITOR.replace( 'editor' );
</script>
32 changes: 32 additions & 0 deletions tests/plugins/list/manual/sublistreverse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@bender-tags: bug, 2721, 4.11.3
@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, toolbar, list, sourcearea, undo, elementspath

1. Place caret in list after dollar symbol (`$`).
1. Press <kbd>Backspace</kbd> two times (once in IE).

## Expected

Sublist is ordered alphabetically:

```
1. Test
1. a
2. b
3. c
```

## Unexpected

Sublist order is reversed:

```
1. Test
1. c
2. b
3. a
```

## Note

There is known upstream issue on IE [#2774](https://github.com/ckeditor/ckeditor-dev/issues/2774) when after pressing <kbd>Backspace</kbd> only `li` element is removed and `ol` is preserved. This results in incorrect markup `ol > li > ol > ol > li`.