Skip to content

Commit c617616

Browse files
committed
feat(MenuItem): added target, referrerpolicy and componentAttrs props
1 parent b12734e commit c617616

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

apps/docs/src/stories/Components/Menu.story.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<story-canvas title="Basic (simplified)">
4545
<pf-menu>
4646
<pf-menu-item>Action</pf-menu-item>
47-
<pf-menu-item to="#default-link2" @click.prevent>Link</pf-menu-item>
47+
<pf-menu-item to="#default-link2" @click.prevent target="_blank">Link</pf-menu-item>
4848
<pf-menu-item disabled>Disabled action</pf-menu-item>
4949
<pf-menu-item disabled to="#default-link4">Disabled link</pf-menu-item>
5050
</pf-menu>

packages/core/src/components/Menu/MenuItem.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
<component
1919
:is="component"
20+
v-bind="componentAttrs"
2021
tabindex="-1"
2122
:class="[styles.menuItem, {[styles.modifiers.selected]: effectiveSelected && !check}]"
2223
:aria-current="ariaCurrent"
@@ -27,6 +28,8 @@
2728
:aria-disabled="component === 'a' && disabled ? disabled : undefined"
2829
:aria-expanded="onPath || flyoutVisible || undefined"
2930
:type="component === 'button' ? 'button' : undefined"
31+
:target="component === 'a' ? target : undefined"
32+
:referrerpolicy="component === 'a' ? referrerpolicy : undefined"
3033
:download="component === 'a' ? download : undefined"
3134
@click="!check && onClick($event)"
3235
>
@@ -114,6 +117,8 @@ export interface Props extends OUIAProps, /* @vue-ignore */ Omit<LiHTMLAttribute
114117
loading?: boolean;
115118
/** Component used to render the menu item */
116119
component?: string;
120+
/** Additional attrs added to the link component */
121+
componentAttrs?: Omit<ButtonHTMLAttributes, 'href' | 'aria-current' | 'disabled' | 'role' | 'for' | 'aria-disabled' | 'aria-expanded' | 'type' | 'download' | 'onClick'> | Omit<AnchorHTMLAttributes, 'href' | 'aria-current' | 'disabled' | 'role' | 'for' | 'aria-disabled' | 'aria-expanded' | 'type' | 'download' | 'onClick' | 'target' | 'referrerpolicy'>;
117122
/** Render item as disabled option */
118123
disabled?: boolean;
119124
/** Description of the menu item */
@@ -132,12 +137,16 @@ export interface Props extends OUIAProps, /* @vue-ignore */ Omit<LiHTMLAttribute
132137
onPath?: boolean;
133138
/** Navigation link download. Only set when the to property is present. */
134139
download?: string;
140+
/** Navigation link target. */
141+
target?: string;
142+
/** Navigation link referrerpolicy. */
143+
referrerpolicy?: AnchorHTMLAttributes['referrerpolicy'];
135144
}
136145
</script>
137146

138147
<script lang="ts" setup>
139148
import styles from '@patternfly/react-styles/css/components/Menu/menu';
140-
import { computed, getCurrentInstance, inject, provide, ref, type ComputedRef, type InjectionKey, type Ref, type LiHTMLAttributes } from 'vue';
149+
import { computed, getCurrentInstance, inject, provide, ref, type ComputedRef, type InjectionKey, type Ref, type LiHTMLAttributes, type ButtonHTMLAttributes, type AnchorHTMLAttributes } from 'vue';
141150
import { getUniqueId } from '../../util';
142151
import { MenuInjectionKey, MenuItemsKey, type MenuItemId } from './Menu.vue';
143152
import PfCheckbox from '../Checkbox.vue';

0 commit comments

Comments
 (0)