Skip to content

Commit b8bca1a

Browse files
author
Hwashiang Yu
committed
MC-5383: Option Menus, Heading Inline Editor & tinyMCE Inline Editor Are Cut Off on Full Screen View
- Removed logic to shift the stage - Added logic to move the editor panel to go below the inline editor on overflow - Updated test for the editor panel change - Updated styling to resolve issue with left hand panel covering hover menu and column resizing menu options
1 parent d69f037 commit b8bca1a

File tree

6 files changed

+72
-44
lines changed

6 files changed

+72
-44
lines changed

app/code/Magento/PageBuilder/Test/Mftf/Test/AdminPageBuilderPanelTest.xml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -534,12 +534,17 @@
534534
<!-- Explicit wait for CSS animation to complete -->
535535
<wait time="1" stepKey="waitForInlineWysiwygToolbarTransitionAnimationToFinish" />
536536
<waitForElementVisible selector="{{PageBuilderStage.inlineWYSIWYGEditorPanel(PageBuilderTextContentType.role, '1')}}" stepKey="waitForWYWSIWYGEditorPanelToBeVisible"/>
537-
<executeJS function="return document.evaluate(`{{PageBuilderStage.inlineWYSIWYGEditorPanel(PageBuilderTextContentType.role, '1')}}`, document.body).iterateNext().getBoundingClientRect().top" stepKey="topBoundingClientRect"/>
538-
<!-- Assert top bounding client rect > 0 -->
539-
<comment userInput="Assert top bounding client rect > 0" stepKey="commentAssertTopBoundingClientRectGreaterThan0" />
540-
<assertGreaterThanOrEqual stepKey="assertTopBoundingClientRectIsGreaterThan0">
537+
<!-- Assert editor panel is below text wysiwyg and not overflow-->
538+
<comment userInput="Assert top editor panel bounding client rect > bottom text wysiwyg bounding client rect when overflow" stepKey="commentAssertWysiwygIsAboveEditorPanel" />
539+
<executeJS function="return document.evaluate(`{{TextOnStage.wysiwyg('1')}}`, document.body).iterateNext().getBoundingClientRect().bottom" stepKey="bottomTextWysiwygClientRect"/>
540+
<executeJS function="return document.evaluate(`{{PageBuilderStage.inlineWYSIWYGEditorPanel(PageBuilderTextContentType.role, '1')}}`, document.body).iterateNext().getBoundingClientRect().top" stepKey="topEditorPanelBoundingClientRect"/>
541+
<assertGreaterThanOrEqual stepKey="assertTopEditorPanelBoundingClientRectIsNotNegative">
541542
<expectedResult type="int">0</expectedResult>
542-
<actualResult type="variable">$topBoundingClientRect</actualResult>
543+
<actualResult type="variable">$topEditorPanelBoundingClientRectInSmallerColumn</actualResult>
544+
</assertGreaterThanOrEqual>
545+
<assertGreaterThanOrEqual stepKey="assertTopEditorPanelBoundingClientRectIsGreaterThanBottomTextWysiwygClientRect">
546+
<expectedResult type="variable">$bottomTextWysiwygClientRect</expectedResult>
547+
<actualResult type="variable">$topEditorPanelBoundingClientRect</actualResult>
543548
</assertGreaterThanOrEqual>
544549
<click selector="{{PageBuilderPanel.searchPanel}}" stepKey="unFocusEditor"/>
545550
<!-- Shrink column down to 1/3 its original size -->
@@ -560,12 +565,17 @@
560565
<!-- Explicit wait for CSS animation to complete -->
561566
<wait time="1" stepKey="waitForInlineWysiwygToolbarTransitionAnimationToFinish2" />
562567
<waitForElementVisible selector="{{PageBuilderStage.inlineWYSIWYGEditorPanel(PageBuilderTextContentType.role, '1')}}" stepKey="waitForWYWSIWYGEditorPanelToBeVisible2"/>
563-
<executeJS function="return document.evaluate(`{{PageBuilderStage.inlineWYSIWYGEditorPanel(PageBuilderTextContentType.role, '1')}}`, document.body).iterateNext().getBoundingClientRect().top" stepKey="topBoundingClientRect2"/>
564-
<!-- Assert top bounding client rect > 0 when column is 1/3 its original size -->
565-
<comment userInput="Assert top bounding client rect > 0 when column is 1/3 its original size" stepKey="commentAssertInlineEditorAppearsInSmallerColumn" />
566-
<assertGreaterThanOrEqual stepKey="assertTopBoundingClientRectIsGreaterThan0InSmallerColumn">
568+
<!-- Assert editor panel is below text wysiwyg and not overflow when column is 1/3 its original size-->
569+
<comment userInput="Assert top editor panel bounding client rect > bottom text wysiwyg bounding client rect when column is 1/3 its original size" stepKey="commentAssertWysiwygIsAboveEditorPanelInSmallerColumn" />
570+
<executeJS function="return document.evaluate(`{{TextOnStage.wysiwyg('1')}}`, document.body).iterateNext().getBoundingClientRect().bottom" stepKey="bottomTextWysiwygClientRectInSmallerColumn"/>
571+
<executeJS function="return document.evaluate(`{{PageBuilderStage.inlineWYSIWYGEditorPanel(PageBuilderTextContentType.role, '1')}}`, document.body).iterateNext().getBoundingClientRect().top" stepKey="topEditorPanelBoundingClientRectInSmallerColumn"/>
572+
<assertGreaterThanOrEqual stepKey="assertTopEditorPanelBoundingClientRectIsNotNegativeInSmallerColumn">
567573
<expectedResult type="int">0</expectedResult>
568-
<actualResult type="variable">$topBoundingClientRect2</actualResult>
574+
<actualResult type="variable">$topEditorPanelBoundingClientRectInSmallerColumn</actualResult>
575+
</assertGreaterThanOrEqual>
576+
<assertGreaterThanOrEqual stepKey="assertTopEditorPanelBoundingClientRectIsGreaterThanBottomTextWysiwygClientRectInSmallerColumn">
577+
<expectedResult type="variable">$bottomTextWysiwygClientRectInSmallerColumn</expectedResult>
578+
<actualResult type="variable">$topEditorPanelBoundingClientRectInSmallerColumn</actualResult>
569579
</assertGreaterThanOrEqual>
570580
</test>
571581
</tests>

app/code/Magento/PageBuilder/view/adminhtml/web/css/source/_inline-wysiwyg.less

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
pointer-events: none;
2222
position: absolute;
2323
transform: translateY(0);
24-
transition: transform 200ms, opacity 200ms, visibility 200ms;
24+
transition: transform 100ms, opacity 400ms, visibility 400ms;
2525
visibility: hidden;
2626
width: auto !important;
2727

@@ -38,12 +38,13 @@
3838
}
3939
&.mce-edit-focus {
4040
outline: none;
41-
4241
~ .mce-tinymce-inline {
4342
opacity: 1;
4443
pointer-events: all;
45-
transform: translateY(-100%);
4644
visibility: visible !important;
45+
&.transform-up {
46+
transform: translateY(-100%);
47+
}
4748
}
4849
}
4950
&._right-aligned-toolbar ~ div.mce-tinymce-inline {

app/code/Magento/PageBuilder/view/adminhtml/web/css/source/content-type/_preview.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@
336336
transform: translate(-50%, -50%);
337337
transition: opacity 200ms, visibility 200ms;
338338
visibility: hidden;
339-
z-index: 30;
339+
z-index: 105;
340340

341341
&.pagebuilder-options-visible {
342342
.pagebuilder-options-visible;

app/code/Magento/PageBuilder/view/adminhtml/web/css/source/content-type/column-group/_default.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
&.resizing,
118118
&.grid-form-open {
119119
.pagebuilder-grid-size-indicator {
120-
z-index: 100;
120+
z-index: 105;
121121
}
122122

123123
.resize-grid {

app/code/Magento/PageBuilder/view/adminhtml/web/js/wysiwyg/tinymce4.js

Lines changed: 23 additions & 14 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/wysiwyg/tinymce4.ts

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export default class Wysiwyg implements WysiwygInterface {
108108
// Update content in our data store after our stage preview wysiwyg gets updated
109109
this.wysiwygAdapter.eventBus.attachEventHandler(
110110
WysiwygEvents.afterChangeContent,
111-
_.debounce(this.saveContentFromWysiwygToDataStore.bind(this), 100),
111+
this.onChangeContent.bind(this),
112112
);
113113

114114
// Update content in our stage preview wysiwyg after its slideout counterpart gets updated
@@ -142,18 +142,30 @@ export default class Wysiwyg implements WysiwygInterface {
142142
.find(".mce-tinymce-inline")
143143
.css("min-width", this.config.adapter_config.minToolbarWidth + "px");
144144

145-
_.delay(this.adjustFullScreenPaddingToAccommodateInlineToolbar.bind(this), 200);
145+
_.delay(this.invertInlineEditorToAccommodateOffscreenToolbar.bind(this), 100);
146146
});
147147
}
148148

149+
/**
150+
* Called for the onChangeContent event
151+
*/
152+
private onChangeContent() {
153+
const saveContent = _.debounce(this.saveContentFromWysiwygToDataStore.bind(this), 100);
154+
saveContent();
155+
_.delay(this.invertInlineEditorToAccommodateOffscreenToolbar.bind(this), 100);
156+
}
157+
149158
/**
150159
* Called for the onBlur events
151160
*/
152161
private onBlur() {
153162
this.clearSelection();
154163

155164
this.getFixedToolbarContainer()
156-
.removeClass("pagebuilder-toolbar-active");
165+
.removeClass("pagebuilder-toolbar-active")
166+
.find(".mce-tinymce-inline")
167+
.removeClass("transform-up")
168+
.css("transform", "");
157169

158170
events.trigger("stage:interactionStop");
159171
}
@@ -193,39 +205,35 @@ export default class Wysiwyg implements WysiwygInterface {
193205
/**
194206
* Adjust padding on stage if in fullscreen mode to accommodate inline wysiwyg toolbar overflowing fixed viewport
195207
*/
196-
private adjustFullScreenPaddingToAccommodateInlineToolbar() {
208+
private invertInlineEditorToAccommodateOffscreenToolbar() {
197209
if (this.config.adapter_config.mode !== "inline") {
198210
return;
199211
}
200212

201213
const $stage = $(`#${this.stageId}`);
202214
const $fullScreenStageWrapper = $stage.closest(".stage-full-screen");
203215
const isInFullScreenMode = !!$fullScreenStageWrapper.length;
216+
const $inlineToolbar = this.getFixedToolbarContainer().find(".mce-tinymce-inline");
204217

205218
if (!isInFullScreenMode) {
219+
$inlineToolbar.addClass("transform-up");
206220
return;
207221
}
208222

209223
_.delay(() => {
210-
const $inlineToolbar = this.getFixedToolbarContainer().find(".mce-tinymce-inline");
211224

212225
if (!$inlineToolbar.length) {
213226
return;
214227
}
215228

216-
const inlineToolbarClientRectTop = $inlineToolbar.get(0).getBoundingClientRect().top;
229+
const inlineWysiwygClientRectTop = this.getFixedToolbarContainer().get(0).getBoundingClientRect().top;
217230

218-
if (inlineToolbarClientRectTop >= 0) { // inline toolbar not out of bounds; continue
231+
if ($inlineToolbar.height() < inlineWysiwygClientRectTop) { // inline toolbar not out of bounds; continue
232+
$inlineToolbar.addClass("transform-up");
219233
return;
220234
}
221-
222-
const currentStagePaddingTop = parseInt($stage.css("paddingTop") || "0", 10);
223-
const paddingTopToApplyToStage = Math.abs(inlineToolbarClientRectTop) + currentStagePaddingTop;
224-
225-
// increase padding top and adjust scrollTop accordingly to make it seamless
226-
$stage.css("paddingTop", paddingTopToApplyToStage);
227-
$fullScreenStageWrapper.scrollTop($fullScreenStageWrapper.scrollTop() + paddingTopToApplyToStage);
228-
}, 200);
235+
$inlineToolbar.css("transform", "translateY(" + this.getFixedToolbarContainer().height() + "px)");
236+
}, 100);
229237
}
230238

231239
/**

0 commit comments

Comments
 (0)