diff --git a/src/js/models/markup-section.js b/src/js/models/markup-section.js index ee15123a5..278d40e67 100644 --- a/src/js/models/markup-section.js +++ b/src/js/models/markup-section.js @@ -37,9 +37,7 @@ const MarkupSection = class MarkupSection extends Markerable { splitAtMarker(marker, offset=0) { let [beforeSection, afterSection] = [ this.builder.createMarkupSection(this.tagName, []), - // FIXME we probably want to make it so that we create a new default markup - // section instead of copying the same tagname to the section below - this.builder.createMarkupSection(this.tagName, []) + this.builder.createMarkupSection() ]; return this._redistributeMarkers(beforeSection, afterSection, marker, offset); diff --git a/tests/acceptance/editor-sections-test.js b/tests/acceptance/editor-sections-test.js index 5d008ba04..0c367c3f5 100644 --- a/tests/acceptance/editor-sections-test.js +++ b/tests/acceptance/editor-sections-test.js @@ -178,6 +178,25 @@ test('hitting enter at end of a section creates new empty section', (assert) => assert.hasElement('#editor p:eq(1):contains(X)', 'text is inserted in the new section'); }); +test('hitting enter in a section creates a new basic section', (assert) => { + const mobiledoc = Helpers.mobiledoc.build(({post, markupSection, marker}) => + post([ + markupSection('h2', [marker('abc')]) + ]) + ); + editor = new Editor({mobiledoc}); + editor.render(editorElement); + assert.hasElement('#editor h2:contains(abc)', 'precond - h2 is there'); + assert.hasNoElement('#editor p', 'precond - no p tag'); + + Helpers.dom.moveCursorTo($('#editor h2')[0].childNodes[0], 'abc'.length); + Helpers.dom.triggerEnter(editor); + Helpers.dom.insertText('X'); + + assert.hasElement('#editor h2:contains(abc)', 'h2 still there'); + assert.hasElement('#editor p:contains(X)', 'p tag instead of h2 generated'); +}); + // Phantom does not recognize toggling contenteditable off Helpers.skipInPhantom('deleting across 2 sections does nothing if editing is disabled', (assert) => { editor = new Editor({mobiledoc: mobileDocWith2Sections});