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

[stable7] enh(NcActions): Navigation link actions #4160

Merged
merged 1 commit into from May 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/components/NcActions/NcActions.vue
Expand Up @@ -960,6 +960,16 @@ export default {
action => action?.componentOptions?.tag || action?.componentOptions?.Ctor?.extendOptions?.name
)

const isNavLink = (action) => {
const componentName = action?.componentOptions?.Ctor?.extendOptions?.name ?? action?.componentOptions?.tag
return (
componentName === 'NcActionLink'
&& action?.componentOptions?.propsData?.href?.startsWith(window.location.origin)
)
}
// Automatically detect whether all actions are website navigation links
const isNav = actions.every(isNavLink)

/**
* Filter and list actions that are allowed to be displayed inline
*/
Expand Down Expand Up @@ -1093,7 +1103,7 @@ export default {
slot: 'trigger',
ref: 'menuButton',
attrs: {
'aria-haspopup': 'menu',
'aria-haspopup': isNav ? null : 'menu',
'aria-label': this.ariaLabel,
'aria-controls': this.opened ? this.randomId : null,
'aria-expanded': this.opened.toString(),
Expand Down Expand Up @@ -1123,7 +1133,7 @@ export default {
attrs: {
id: this.randomId,
tabindex: '-1',
role: 'menu',
role: isNav ? null : 'menu',
},
}, [
actions,
Expand Down