Make animation an explicit flag on deleteBlock / duplicateBlock (and test in non-animated mode)

pull/6931/head
Matt Westcott 2021-03-09 16:15:32 +00:00
rodzic 773da59107
commit 7361b0901f
5 zmienionych plików z 16 dodań i 13 usunięć

Wyświetl plik

@ -237,8 +237,8 @@ export class BaseSequenceBlock {
const child = this._createChild(childBlockDef, blockPlaceholder, prefix, index, id, initialState, {
animate,
onRequestDuplicate: (i) => { this.duplicateBlock(i); },
onRequestDelete: (i) => { this.deleteBlock(i); },
onRequestDuplicate: (i) => { this.duplicateBlock(i, { animate: true }); },
onRequestDelete: (i) => { this.deleteBlock(i, { animate: true }); },
onRequestMoveUp: (i) => { this.moveBlock(i, i - 1); },
onRequestMoveDown: (i) => { this.moveBlock(i, i + 1); },
strings: this.blockDef.meta.strings,
@ -278,8 +278,9 @@ export class BaseSequenceBlock {
return child;
}
deleteBlock(index) {
this.children[index].markDeleted({ animate: true });
deleteBlock(index, opts) {
const animate = opts && opts.animate;
this.children[index].markDeleted({ animate });
this.inserters[index].delete();
this.children.splice(index, 1);
this.inserters.splice(index, 1);

Wyświetl plik

@ -111,9 +111,10 @@ export class ListBlock extends BaseSequenceBlock {
return this._insert(this.blockDef.childBlockDef, value, null, index, opts);
}
duplicateBlock(index) {
duplicateBlock(index, opts) {
const childState = this.children[index].getState();
this.insert(childState, index + 1, { animate: true });
const animate = opts && opts.animate;
this.insert(childState, index + 1, { animate });
this.children[index + 1].focus({ soft: true });
}

Wyświetl plik

@ -291,18 +291,19 @@ export class StreamBlock extends BaseSequenceBlock {
this.checkBlockCounts();
}
duplicateBlock(index) {
duplicateBlock(index, opts) {
const childState = this.children[index].getState();
const animate = opts && opts.animate;
childState.id = null;
this.insert(childState, index + 1, { animate: true });
this.insert(childState, index + 1, { animate });
// focus the newly added field if we can do so without obtrusive UI behaviour
this.children[index + 1].focus({ soft: true });
this.checkBlockCounts();
}
deleteBlock(index) {
super.deleteBlock(index);
deleteBlock(index, opts) {
super.deleteBlock(index, opts);
this.checkBlockCounts();
}

Wyświetl plik

@ -105,7 +105,7 @@ exports[`telepath: wagtail.blocks.ListBlock blocks can be duplicated 1`] = `
</div>
</div><button type=\\"button\\" title=\\"Add\\" data-streamfield-list-add=\\"\\" class=\\"c-sf-add-button c-sf-add-button--visible\\">
<i aria-hidden=\\"true\\">+</i>
</button><div aria-hidden=\\"false\\" style=\\"overflow: hidden;\\">
</button><div aria-hidden=\\"false\\">
<input type=\\"hidden\\" name=\\"the-prefix-2-deleted\\" value=\\"\\">
<input type=\\"hidden\\" name=\\"the-prefix-2-order\\" value=\\"2\\">
<input type=\\"hidden\\" name=\\"the-prefix-2-type\\" value=\\"\\">
@ -432,7 +432,7 @@ exports[`telepath: wagtail.blocks.ListBlock deleteBlock() deletes a block 1`] =
</div>
</div><button type=\\"button\\" title=\\"Add\\" data-streamfield-list-add=\\"\\" class=\\"c-sf-add-button c-sf-add-button--visible\\" style=\\"display: none;\\" aria-hidden=\\"true\\">
<i aria-hidden=\\"true\\">+</i>
</button><div aria-hidden=\\"true\\" style=\\"overflow: hidden; height: 0px; padding-top: 0px; margin-top: 0px; padding-bottom: 0px; margin-bottom: 0px;\\">
</button><div aria-hidden=\\"true\\" style=\\"display: none;\\">
<input type=\\"hidden\\" name=\\"the-prefix-1-deleted\\" value=\\"1\\">
<input type=\\"hidden\\" name=\\"the-prefix-1-order\\" value=\\"1\\">
<input type=\\"hidden\\" name=\\"the-prefix-1-type\\" value=\\"\\">

Wyświetl plik

@ -119,7 +119,7 @@ exports[`telepath: wagtail.blocks.StreamBlock blocks can be duplicated 1`] = `
<div data-streamblock-menu-outer=\\"\\" style=\\"display: none;\\" aria-hidden=\\"true\\">
<div data-streamblock-menu-inner=\\"\\" class=\\"c-sf-add-panel\\"></div>
</div>
</div><div aria-hidden=\\"false\\" style=\\"overflow: hidden; height: 0px; padding-top: 0px; margin-top: 0px; padding-bottom: 0px; margin-bottom: 0px;\\">
</div><div aria-hidden=\\"false\\">
<input type=\\"hidden\\" name=\\"the-prefix-2-deleted\\" value=\\"\\">
<input type=\\"hidden\\" name=\\"the-prefix-2-order\\" value=\\"2\\">
<input type=\\"hidden\\" name=\\"the-prefix-2-type\\" value=\\"test_block_b\\">