Skip to content

Commit da419c5

Browse files
committed
#609: Content Type Toolbar hidden under PageBuilder header in Full screen - Fixed Content Type Toolbar translateY calculation
1 parent 7ef5f37 commit da419c5

File tree

5 files changed

+31
-7
lines changed

5 files changed

+31
-7
lines changed

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

Lines changed: 4 additions & 3 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/js/wysiwyg/tinymce4.js

Lines changed: 2 additions & 2 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-toolbar.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Preview from "./content-type/preview";
1111
import {PreviewCollectionInterface} from "./content-type/preview-collection.types";
1212
import {PreviewInterface} from "./content-type/preview.types";
1313
import checkStageFullScreen from "./utils/check-stage-full-screen";
14+
import pageBuilderHeaderHeight from "./utils/pagebuilder-header-height";
1415
import deferred, {DeferredInterface} from "./utils/promise-deferred";
1516

1617
/**
@@ -78,9 +79,11 @@ export default class Toolbar {
7879
public onFocusIn(context: ContentTypeToolbarPreviewInterface, event: Event): void {
7980
const currentContentTypeTarget = context.toolbar.getCurrentContentTypeTarget();
8081
const toolbarOptions = currentContentTypeTarget.find(".pagebuilder-toolbar-options");
82+
const currentContentTypeTargetClientRectTop = currentContentTypeTarget[0].getBoundingClientRect().top
83+
- pageBuilderHeaderHeight(context.contentType.stageId);
8184
// Change toolbar orientation if overflow on full screen mode
8285
if (checkStageFullScreen(context.contentType.stageId)
83-
&& currentContentTypeTarget[0].getBoundingClientRect().top < toolbarOptions.outerHeight()
86+
&& currentContentTypeTargetClientRectTop < toolbarOptions.outerHeight()
8487
) {
8588
context.toolbar.observer = new MutationObserver(() => {
8689
toolbarOptions.css("transform", "translateY(" + currentContentTypeTarget.outerHeight() + "px)");
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
import $ from "jquery";
7+
8+
/**
9+
* Checks if PageBuilder has header and return it's height
10+
*
11+
* @param {string} stageId
12+
* @returns {number}
13+
*/
14+
export default function pageBuilderHeaderHeight(stageId: string): number {
15+
const $stageWrapper = $("#" + stageId).closest('.pagebuilder-stage-wrapper');
16+
const $pageBuilderHeader = $stageWrapper.find('.pagebuilder-header');
17+
return (!!$pageBuilderHeader.length) ? $pageBuilderHeader.height() : 0;
18+
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import WysiwygInstanceInterface from "wysiwygAdapter";
1212
import {AdditionalDataConfigInterface} from "../content-type-config.types";
1313
import DataStore from "../data-store";
1414
import checkStageFullScreen from "../utils/check-stage-full-screen";
15+
import pageBuilderHeaderHeight from "../utils/pagebuilder-header-height";
1516
import WysiwygInterface from "./wysiwyg-interface";
1617

1718
/**
@@ -203,7 +204,8 @@ export default class Wysiwyg implements WysiwygInterface {
203204
return;
204205
}
205206

206-
const inlineWysiwygClientRectTop = this.getFixedToolbarContainer().get(0).getBoundingClientRect().top;
207+
const inlineWysiwygClientRectTop = this.getFixedToolbarContainer().get(0).getBoundingClientRect().top
208+
- pageBuilderHeaderHeight(this.stageId);
207209

208210
if (!checkStageFullScreen(this.stageId) || $inlineToolbar.height() < inlineWysiwygClientRectTop) {
209211
$inlineToolbar.css("transform", "translateY(-100%)");

0 commit comments

Comments
 (0)