Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix icon-class, re-add default-icon support for Actions #3017

Merged
merged 1 commit into from
Aug 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 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,15 @@ export default {
* Otherwise, we render the actions in a popover
*/
} else {
const triggerIcon = this.$slots.icon?.[0] || h('DotsHorizontal', {
props: {
size: 20,
},
})
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