Skip to content

Commit 2535074

Browse files
committed
MC-3690: Buttons Do Not Resize When Buttons Are In Parent And Parent Is Resized
- resize buttons on after stage update
1 parent d09bdbd commit 2535074

File tree

3 files changed

+20
-52
lines changed

3 files changed

+20
-52
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/buttons/preview.js

Lines changed: 4 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type/buttons/preview.ts

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@ import $ from "jquery";
77
import ko from "knockout";
88
import $t from "mage/translate";
99
import events from "Magento_PageBuilder/js/events";
10+
import _ from "underscore";
1011
import {SortableOptionsInterface} from "../../binding/sortable-options";
1112
import Config from "../../config";
1213
import ContentTypeInterface from "../../content-type";
1314
import createContentType from "../../content-type-factory";
1415
import Option from "../../content-type-menu/option";
1516
import OptionInterface from "../../content-type-menu/option.d";
16-
import ContentTypeAfterRenderEventParamsInterface from "../content-type-after-render-event-params";
17+
import StageUpdateAfterParamsInterface from "../../stage-update-after-params.d";
1718
import ContentTypeDroppedCreateEventParamsInterface from "../content-type-dropped-create-event-params";
18-
import ContentTypeRemovedEventParamsInterface from "../content-type-removed-event-params";
1919
import PreviewCollection from "../preview-collection";
20-
import PreviewDataUpdateAfterParamsInterface from "../preview-data-update-after-params";
2120

2221
/**
2322
* @api
@@ -45,32 +44,10 @@ export default class Preview extends PreviewCollection {
4544
}
4645
});
4746

48-
events.on("previewData:updateAfter", (eventData: PreviewDataUpdateAfterParamsInterface) => {
49-
const contentTypePreview = eventData.preview;
50-
if ((contentTypePreview.config.name === "button-item"
51-
&& contentTypePreview.parent.parent.id === this.parent.id)
52-
|| (contentTypePreview.config.name === "buttons"
53-
&& contentTypePreview.parent.id === this.parent.id)) {
47+
events.on("stage:updateAfter", (eventData: StageUpdateAfterParamsInterface) => {
48+
_.debounce(() => {
5449
this.resizeChildButtons();
55-
}
56-
});
57-
58-
events.on("buttons:renderAfter", (eventData: ContentTypeAfterRenderEventParamsInterface) => {
59-
if (eventData.contentType.id === this.parent.id) {
60-
this.resizeChildButtons();
61-
}
62-
});
63-
64-
events.on("button-item:renderAfter", (eventData: ContentTypeAfterRenderEventParamsInterface) => {
65-
if (eventData.contentType.parent.id === this.parent.id) {
66-
this.resizeChildButtons();
67-
}
68-
});
69-
70-
events.on("button-item:removeAfter", (eventData: ContentTypeRemovedEventParamsInterface) => {
71-
if (eventData.parent.id === this.parent.id) {
72-
this.resizeChildButtons();
73-
}
50+
}, 500).call(this);
7451
});
7552
}
7653

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
/**
7+
* @api
8+
*/
9+
export default interface StageUpdateAfterParamsInterface {
10+
stageId: string;
11+
}

0 commit comments

Comments
 (0)