Skip to content

Commit 9b68213

Browse files
author
Cari Spruiell
committed
MAGETWO-91367: Tab's drag handle should be disabled when there is only one tab
- disable drag handle when there is only one tab
1 parent 2953f58 commit 9b68213

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@
6060
visibility: hidden;
6161
width: 14px;
6262

63+
&.disabled:before {
64+
color: @color-light-gray;
65+
cursor: not-allowed;
66+
}
67+
68+
&.disabled:active:before {
69+
cursor: not-allowed;
70+
}
71+
6372
&:before {
6473
.abs-icon;
6574
color: @color-dark-gray0;

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

Lines changed: 11 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/template/content-type/tabs/default/preview.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<li role="tab" class="tab-header" css="{focused: parent.parent.preview.focusedTab() === $index()}" click="function (context, event) { parent.parent.preview.onTabClick($index(), event); }" ko-style="parent.parent.preview.getTabHeaderStyles()">
1414
<a href="#no-tab" class="tab-title focus-options" attr="{ href: '#' + parent.id }">
1515
<render args="getOptions().template" />
16-
<span class="tab-drag-handle"></span>
16+
<span class="tab-drag-handle" css="{disabled: parent.parent.children().length <= 1}"></span>
1717
<span class="tab-title tab-name" data-tab-title="true" data-bind="liveEdit: { field: 'tab_name', placeholder: $t('...') }, hasFocusNoScroll: parent.parent.preview.focusedTab() === $index()" event="{ focusin: function () { parent.parent.preview.setFocusedTab($index(), true) }, focusout: function () { window.getSelection().removeAllRanges(); parent.parent.preview.setFocusedTab(null); } }"></span>
1818
</a>
1919
</li>

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ export default class Preview extends PreviewCollection {
121121
} else if (activeIndex) {
122122
this.setActiveTab(activeIndex);
123123
}
124+
// update sortability of tabs
125+
const sortableElement = $(this.element).find(".tabs-navigation");
126+
if (sortableElement.hasClass("ui-sortable")) {
127+
if (this.parent.children().length <= 1) {
128+
sortableElement.sortable("disable");
129+
} else {
130+
sortableElement.sortable("enable");
131+
}
132+
}
124133
}
125134
}
126135

0 commit comments

Comments
 (0)