Skip to content

Commit

Permalink
Fix Actions icon-class, re-add default-icon support
Browse files Browse the repository at this point in the history
Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
  • Loading branch information
raimund-schluessler committed Aug 12, 2022
1 parent b4cbd40 commit a313166
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/components/Actions/Actions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,16 @@ export default {
default: null,
},
/**
* Icon to show for the toggle menu button
* when more than one action is inside the actions component.
* Only replace the default three-dot icon if really necessary.
*/
defaultIcon: {
type: String,
default: '',
},
/**
* Aria label for the actions menu
*/
Expand Down Expand Up @@ -730,7 +740,7 @@ export default {
*/
if (this.isValidSingleAction(actions) && !this.forceMenu) {
const firstAction = actions[0]
const icon = firstAction?.data?.scopedSlots?.icon()?.[0]
const icon = firstAction?.data?.scopedSlots?.icon()?.[0] || h('span', { class: ['icon', firstAction?.componentOptions?.propsData?.icon ] })
const title = this.forceTitle ? this.menuTitle : ''
const clickListener = firstAction?.componentOptions?.listeners?.click
return h('ButtonVue',
Expand All @@ -739,8 +749,6 @@ export default {
'action-item action-item--single',
firstAction?.data?.staticClass,
firstAction?.data?.class,
// use icon attribute as class if icon slot is not used
icon ? undefined : firstAction?.componentOptions?.propsData?.icon,
],
attrs: {
'aria-label': firstAction?.componentOptions?.propsData?.ariaLabel || firstAction?.componentOptions?.children?.[0]?.text,
Expand Down Expand Up @@ -782,11 +790,14 @@ export default {
* Otherwise, we render the actions in a popover
*/
} else {
const triggerIcon = this.$slots.icon?.[0] || h('DotsHorizontal', {
const triggerIcon = this.$slots.icon?.[0] || (
this.defaultIcon
? h('span', { class: ['icon', this.defaultIcon ] })
: h('DotsHorizontal', {
props: {
size: 20,
},
})
}))
return h('div',
{
class: [
Expand Down

0 comments on commit a313166

Please sign in to comment.