Skip to content

Commit 6fa971b

Browse files
authored
[6.x] Fix Bard set disappearing after save (#14956)
1 parent aa49838 commit 6fa971b

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

resources/js/components/fieldtypes/bard/BardFieldtype.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ export default {
448448
const content = this.valueToContent(value);
449449
450450
if (JSON.stringify(content) !== JSON.stringify(oldContent)) {
451-
this.editor.commands.clearContent();
451+
this.editor.commands.clearContent(false);
452452
this.editor.commands.setContent(content, true);
453453
}
454454
},

tests/Fieldtypes/BardTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,36 @@ public function it_removes_empty_nodes()
631631
]);
632632
}
633633

634+
#[Test]
635+
public function it_does_not_remove_sets_when_trimming_empty_nodes()
636+
{
637+
$content = [
638+
['type' => 'paragraph'],
639+
[
640+
'type' => 'set',
641+
'attrs' => [
642+
'id' => 'test-set',
643+
'values' => [
644+
'type' => 'one',
645+
],
646+
],
647+
],
648+
['type' => 'paragraph'],
649+
];
650+
651+
$this->assertEquals([
652+
[
653+
'type' => 'set',
654+
'attrs' => [
655+
'id' => 'test-set',
656+
'values' => [
657+
'type' => 'one',
658+
],
659+
],
660+
],
661+
], $this->bard(['remove_empty_nodes' => 'trim'])->process($content));
662+
}
663+
634664
#[Test]
635665
#[DataProvider('groupedSetsProvider')]
636666
public function it_preloads($areSetsGrouped)

0 commit comments

Comments
 (0)