Skip to content

Commit

Permalink
KAD-4115 move tab options added to toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbert-hernandez committed Mar 3, 2025
1 parent 40f935b commit 24cdd7d
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions src/blocks/tabs/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ import {
TextControl,
ToolbarButton,
ToolbarGroup,
MenuGroup,
MenuItem,
ToolbarDropdownMenu,
} from '@wordpress/components';
import { applyFilters } from '@wordpress/hooks';
import { plusCircle } from '@wordpress/icons';
Expand Down Expand Up @@ -1438,6 +1441,62 @@ function KadenceTabs(props) {
label={__('Add Tab', 'kadence-blocks')}
showTooltip={true}
/>
<ToolbarDropdownMenu
icon="menu"
label={__('Move Tabs', 'kadence-blocks')}
>
{({ onClose }) => (
<MenuGroup>
{/* Move Item Back/Up */}
{ currentTab !== 1 && (
<MenuItem
icon={'vtabs' === layout ? 'arrow-up' : 'arrow-left'}
onClick={ currentTab === 1 ? undefined : onMoveBack(currentTab -1) }
>
{'vtabs' === layout ? __('Move Item Up', 'kadence-blocks') : __('Move Item Back', 'kadence-blocks')}
</MenuItem>
)}
{/* Move Item Forward/Down */}
{currentTab !== tabCount && (
<MenuItem
icon={'vtabs' === layout ? 'arrow-down' : 'arrow-right'}
onClick={ currentTab === tabCount ? undefined : onMoveForward(currentTab - 1) }
>
{'vtabs' === layout ? __('Move Item Down', 'kadence-blocks') : __('Move Item Forward', 'kadence-blocks')}
</MenuItem>
)}
{/* Remove Item */}
{tabCount > 1 && (
<MenuItem
icon="no-alt"
onClick={() => {
const currentItems = filter(titles, (item, i) => currentTab !== i);
const newCount = tabCount - 1;
let newStartTab;
if (startTab === currentTab + 1) {
newStartTab = '';
} else if (startTab > currentTab + 1) {
newStartTab = startTab - 1;
} else {
newStartTab = startTab;
}
removeTab(currentTab);
setAttributes({
titles: currentItems,
tabCount: newCount,
currentTab: currentTab === 0 ? 1 : currentTab,
startTab: newStartTab,
});
resetOrder();
onClose();
}}
>
{__('Remove Item', 'kadence-blocks')}
</MenuItem>
)}
</MenuGroup>
)}
</ToolbarDropdownMenu>
</ToolbarGroup>
</BlockControls>
{showSettings('allSettings', 'kadence/tabs') && (
Expand Down

0 comments on commit 24cdd7d

Please sign in to comment.