Skip to content

Commit 5a08db0

Browse files
committed
MC-5423: Scheduled Update slide out issues
- Re-write panel implementation to use position sticky
1 parent a9381a7 commit 5a08db0

File tree

5 files changed

+72
-6
lines changed

5 files changed

+72
-6
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/css/source/_panel.less

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,13 @@
4747
}
4848

4949
.pagebuilder-panel-wrapper {
50+
bottom: 0;
5051
display: none;
5152
float: left;
5253
position: relative;
54+
position: -webkit-sticky;
55+
position: sticky;
56+
top: 87px;
5357
width: 150px;
5458

5559
&.visible {
@@ -309,8 +313,5 @@
309313
}
310314

311315
.modal-slide .modal-content .pagebuilder-panel-wrapper {
312-
position: -webkit-sticky;
313-
position: sticky;
314316
top: 10px;
315-
bottom: 0;
316317
}

app/code/Magento/PageBuilder/view/adminhtml/web/js/panel.js

Lines changed: 5 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/js/utils/position-sticky.js

Lines changed: 32 additions & 0 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/panel.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import PageBuilder from "./page-builder";
1717
import PanelInterface from "./panel.d";
1818
import {Group} from "./panel/group";
1919
import {ContentType as GroupContentType} from "./panel/group/content-type";
20+
import {supportsPositionSticky} from "./utils/position-sticky";
2021

2122
/**
2223
* @api
@@ -60,7 +61,9 @@ export default class Panel implements PanelInterface {
6061
public initListeners(): void {
6162
events.on("stage:" + this.id + ":readyAfter", () => {
6263
this.populateContentTypes();
63-
this.onScroll();
64+
if (!supportsPositionSticky()) {
65+
this.onScroll();
66+
}
6467
this.isVisible(true);
6568
});
6669
}
@@ -180,6 +183,7 @@ export default class Panel implements PanelInterface {
180183
* @returns {JQueryUI.DraggableOptions}
181184
*/
182185
public getDraggableOptions(element: HTMLElement): JQueryUI.DraggableOptions {
186+
// If we're within a modal make the containment be the current modal
183187
let containment: string | JQuery = "document";
184188
if ($(element).parents(".modal-inner-wrap").length > 0) {
185189
containment = $(element).parents(".modal-inner-wrap");
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
/**
7+
* Determine if the current browser supports position sticky
8+
*
9+
* @returns {boolean}
10+
*/
11+
export function supportsPositionSticky() {
12+
if (!window.getComputedStyle) {
13+
return false;
14+
}
15+
16+
const testNode = document.createElement('div');
17+
18+
return ['', '-webkit-', '-moz-', '-ms-'].some(prefix => {
19+
try {
20+
testNode.style.position = prefix + 'sticky';
21+
}
22+
catch(e) {}
23+
24+
return testNode.style.position != '';
25+
})
26+
}

0 commit comments

Comments
 (0)