Skip to content

Commit

Permalink
forceMenu override inline
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Aug 18, 2022
1 parent 40e15b0 commit 13d77b0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/components/Actions/Actions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ import Tooltip from '../../directives/Tooltip/index.js'
import GenRandomId from '../../utils/GenRandomId.js'
import { t } from '../../l10n.js'
import Vue from 'vue'
import DotsHorizontal from 'vue-material-design-icons/DotsHorizontal.vue'
const focusableSelector = '.focusable'
Expand Down Expand Up @@ -796,7 +797,11 @@ export default {
/**
* Filter and list actions that are allowed to be displayed inline
*/
const inlineActions = actions.filter(this.isValidSingleAction)
let inlineActions = actions.filter(this.isValidSingleAction)
if (this.forceMenu && inlineActions.length > 0 && this.inline > 0) {
Vue.util.warn('Specifying forceMenu will ignore any inline actions rendering.')
inlineActions = []
}
// Check that we have at least one action
if (actions.length === 0) {
Expand Down Expand Up @@ -984,18 +989,20 @@ export default {
// Render inline actions
...renderedInlineActions.map(renderInlineAction),
// render the rest within the popover menu
h('div',
{
class: [
'action-item',
{
'action-item--open': this.opened,
},
],
},
[
renderActionsPopover(menuActions),
]),
menuActions.length > 0
? h('div',
{
class: [
'action-item',
{
'action-item--open': this.opened,
},
],
},
[
renderActionsPopover(menuActions),
])
: null,
])
}
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/components/Actions/Actions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ describe('Actions.vue', () => {
expect(wrapper.findAll('button.action-item').length).toBe(3)
expect(wrapper.find('.action-item__menutoggle').exists()).toBe(false)
})
it('shows the menu toggle when forced.', async () => {
await wrapper.setProps({ forceMenu: true })
expect(wrapper.findAll('button.action-item').length).toBe(0)
expect(wrapper.find('.action-item__menutoggle').exists()).toBe(true)
})
})
})
})

0 comments on commit 13d77b0

Please sign in to comment.