Skip to content

Commit 4d98029

Browse files
author
Hwashiang Yu
committed
MC-3732: Buttons Do Not Display As Same Width After Page Refresh When There's A Lot Of Page Content
- Added resizing logic to not lose width on tab switching
1 parent af2ab79 commit 4d98029

File tree

2 files changed

+19
-9
lines changed
  • app/code/Magento/PageBuilder/view/adminhtml/web

2 files changed

+19
-9
lines changed

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

Lines changed: 10 additions & 5 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: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import PreviewCollection from "../preview-collection";
2424
*/
2525
export default class Preview extends PreviewCollection {
2626
public isLiveEditing: KnockoutObservable<boolean> = ko.observable(false);
27+
public currentMaxWidth: KnockoutObservable<number> = ko.observable(0);
2728
/**
2829
* Keeps track of number of button item to disable sortable if there is only 1.
2930
*/
@@ -242,12 +243,16 @@ export default class Preview extends PreviewCollection {
242243
if (buttonItems.length > 0) {
243244
buttonItems.css("min-width", "");
244245
const currentLargestButton = this.findLargestButton(buttonItems);
245-
buttonResizeValue = currentLargestButton.outerWidth();
246+
const currentLargestButtonWidth = currentLargestButton.outerWidth();
247+
if (currentLargestButtonWidth !== 0) {
248+
buttonResizeValue = currentLargestButtonWidth;
249+
this.currentMaxWidth(currentLargestButtonWidth);
250+
} else {
251+
buttonResizeValue = this.currentMaxWidth();
252+
}
246253
}
247254
}
248-
if (buttonResizeValue > 0) {
249-
buttonItems.css("min-width", buttonResizeValue);
250-
}
255+
buttonItems.css("min-width", buttonResizeValue);
251256
}
252257
}
253258

0 commit comments

Comments
 (0)