Skip to content

Commit

Permalink
prevent selecting transactions tab from the dropdown on edit
Browse files Browse the repository at this point in the history
  • Loading branch information
i-just committed Nov 10, 2023
1 parent 56871a2 commit 76c38c6
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/web/assets/commerceui/src/js/order/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,39 @@ export default new Vuex.Store({
let $transactionsTabContent =
window.document.querySelector('#transactionsTab');
$transactionsTabContent.classList.add('hidden');

// for the dropdown tab menu
const tabManager = Craft.cp.tabManager;
const tabsDropdownMenu = tabManager.$menuBtn.data('menubtn').menu;
const transactionsOption = tabsDropdownMenu.$container
.find('[data-id="order-transactions"]');

// this will disable clicking on the transactions option in the dropdown tab menu
if (transactionsOption.length > 0) {
$(transactionsOption)
.disable()
.attr('disabled', 'disabled')
.css('pointer-events', 'none');
}

// and this is a fallback for selecting the transactions tab differently
let $prevSelectedTab = null;
let $selectedTab = tabManager.$selectedTab[0];

tabManager.on('selectTab', function(ev) {
$prevSelectedTab = $selectedTab;
$selectedTab = $(ev.$tab[0]);
});

tabsDropdownMenu.on(
'optionselect',
function (ev) {
let $selectedOption = $(ev.selectedOption);
if ($selectedOption.data('id') === 'order-transactions') {
$prevSelectedTab.trigger('click');
}
}
);
},

edit({commit, state, dispatch}) {
Expand Down

0 comments on commit 76c38c6

Please sign in to comment.