Skip to content

Commit ef9d627

Browse files
committed
ACP2E-1441: Duplicated page builder elements are not being updated on save
1 parent 034e219 commit ef9d627

File tree

3 files changed

+69
-9
lines changed

3 files changed

+69
-9
lines changed

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

Lines changed: 37 additions & 8 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/template/content-type/text/default/preview.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
css="data.main.css"
1313
afterRender="afterRenderWysiwyg"
1414
contenteditable="true"
15-
event="mousedown: stopEvent, click: activateEditor, dblclick: handleDoubleClick">
15+
event="mousedown: handleMouseDown, click: activateEditor, dblclick: handleDoubleClick">
1616
</div>
1717
<div if="isWysiwygSupported()" class="placeholder-text" ifnot="data.main.html" ko-style="getPlaceholderStyle()" translate="'Edit Text'"></div>
1818

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,37 @@ export default class Preview extends BasePreview {
239239
});
240240
}
241241

242+
/**
243+
* Handle "mousedown" event
244+
*
245+
* @param {Preview} preview
246+
* @param {JQueryEventObject} event
247+
* @returns {Boolean}
248+
*/
249+
public handleMouseDown(preview: Preview, event: JQueryEventObject) {
250+
const handleMouseUp = (mouseUpEvent: JQueryEventObject) => {
251+
if (this.element
252+
&& !this.wysiwyg
253+
&& document.activeElement === this.element
254+
// Check that mouseup occurred outside the element, otherwise "click" event will be triggerred in which
255+
// case we don't need to do anything as the "click" event handled in "activateEditor"
256+
// Note: click is fired after a full click action occurs; that is, the mouse button is pressed
257+
// and released while the pointer remains inside the same element.
258+
&& this.element !== mouseUpEvent.target
259+
&& !$.contains(this.element, mouseUpEvent.target)
260+
) {
261+
this.activateEditor(this, mouseUpEvent);
262+
}
263+
$(document).off("mouseup", handleMouseUp);
264+
return true;
265+
};
266+
267+
event.stopPropagation();
268+
$(document).on("mouseup", handleMouseUp);
269+
270+
return true;
271+
}
272+
242273
/**
243274
* @param {HTMLTextAreaElement} element
244275
*/

0 commit comments

Comments
 (0)