Skip to content

Commit 78e4018

Browse files
committed
Merge remote-tracking branch 'origin/MC-3709-grab-button-handles-displays' into cms-team-2-sprint-15-bugs
2 parents 6cab1b1 + 0baaca1 commit 78e4018

File tree

6 files changed

+91
-5
lines changed

6 files changed

+91
-5
lines changed

app/code/Magento/PageBuilder/Test/Mftf/ActionGroup/ContentTypeButtonActionGroup.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
</arguments>
1515
<comment userInput="Adding Button" stepKey="comment"/>
1616
<executeJS function="return Math.round(document.getElementsByClassName('pagebuilder-button-item').length+1)" stepKey="initialNumberOfButtonsPlusOne"/>
17+
<click selector="{{PageBuilderPanel.searchPanel}}" stepKey="unfocusButtonLiveEdit1"/>
1718
<moveMouseOver selector="{{PageBuilderStage.contentTypeInStageByIndex(PageBuilderButtonsContentType.role, buttonGroupIndex)}}" stepKey="mouseOverButtonsGroup"/>
1819
<waitForPageLoad stepKey="waitForPageLoad"/>
1920
<waitForElementVisible time="10" selector="{{PageBuilderContentTypeOptionsMenu.contentTypeOptionsMenu(PageBuilderButtonsContentType.role)}}" stepKey="waitForOptionsMenu"/>
@@ -25,7 +26,7 @@
2526
<expectedResult type="variable">initialNumberOfButtonsPlusOne</expectedResult>
2627
<actualResult type="variable">numberOfButtonsAfterAdd</actualResult>
2728
</assertEquals>
28-
<click selector="{{PageBuilderPanel.searchPanel}}" stepKey="unfocusButtonLiveEdit"/>
29+
<click selector="{{PageBuilderPanel.searchPanel}}" stepKey="unfocusButtonLiveEdit2"/>
2930
</actionGroup>
3031
<actionGroup name="validateButtonItemContent">
3132
<arguments>

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

Lines changed: 43 additions & 1 deletion
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/js/content-type/buttons/preview.js

Lines changed: 2 additions & 1 deletion
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/template/content-type/button-item/default/preview.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
-->
77

8-
<div attr="data.main.attributes" ko-style="data.main.style" css="data.main.css" class="pagebuilder-content-type pagebuilder-button-item no-system-border focus-options" event="{ click: onMouseOver, focusout: onMouseOut }">
8+
<div attr="data.main.attributes" ko-style="data.main.style" css="data.main.css" class="pagebuilder-content-type pagebuilder-button-item no-system-border focus-options" event="{ click: onButtonClick, focusout: onBlur }">
99
<render args="getOptions().template" />
1010
<a attr="data.link.attributes" ko-style="data.link.style" css="data.link.css">
1111
<span class="button-item-drag-handle" css="{disabled: parent.parent.children().length <= 1}"></span>

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* See COPYING.txt for license details.
44
*/
55

6+
import $ from "jquery";
67
import $t from "mage/translate";
78
import ConditionalRemoveOption from "../../content-type-menu/conditional-remove-option";
89
import {OptionsInterface} from "../../content-type-menu/option.d";
@@ -30,6 +31,46 @@ export default class Preview extends BasePreview {
3031
return options;
3132
}
3233

34+
/**
35+
* Set state based on button click event for the preview
36+
*
37+
* @param {Preview} context
38+
* @param {Event} event
39+
*/
40+
public onButtonClick(context: Preview, event: Event): void {
41+
42+
// Ensure no other options panel and button drag handles are displayed
43+
$(".pagebuilder-content-type-active").removeClass("pagebuilder-content-type-active");
44+
$(".pagebuilder-options-visible").removeClass("pagebuilder-options-visible");
45+
const currentTarget = $(event.currentTarget);
46+
let optionsMenu = $(currentTarget).find(".pagebuilder-options-wrapper");
47+
48+
if (!$(currentTarget).hasClass("type-nested")) {
49+
optionsMenu = optionsMenu.first();
50+
}
51+
$(currentTarget).find("[data-element='link_text']").focus();
52+
optionsMenu.parent().addClass("pagebuilder-options-visible");
53+
$(currentTarget).addClass("pagebuilder-content-type-active");
54+
}
55+
56+
/**
57+
* Set state based on blur event for the preview
58+
*
59+
* @param {Preview} context
60+
* @param {Event} event
61+
*/
62+
public onBlur(context: Preview, event: Event) {
63+
const currentTarget = event.currentTarget;
64+
let optionsMenu = $(currentTarget).find(".pagebuilder-options-wrapper");
65+
66+
if (!$(currentTarget).hasClass("type-nested")) {
67+
optionsMenu = optionsMenu.first();
68+
}
69+
70+
optionsMenu.parent().removeClass("pagebuilder-options-visible");
71+
$(currentTarget).removeClass("pagebuilder-content-type-active");
72+
}
73+
3374
/**
3475
* Focus out of the element
3576
*/

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,9 @@ export default class Preview extends PreviewCollection {
222222
/**
223223
* Logic for post sorting and removing the placeholderGhost
224224
*/
225-
stop() {
225+
stop(event: Event, element: JQueryUI.SortableUIParams) {
226226
placeholderGhost.remove();
227+
element.item.find(".pagebuilder-content-type-active").removeClass("pagebuilder-content-type-active");
227228
events.trigger("stage:interactionStop");
228229
},
229230
};

0 commit comments

Comments
 (0)