Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions docs/components/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,8 @@ a sharp 0px border radius.](images/menu/theming.webp)
| `disabled` | `disabled` | `boolean` | `false` | Disables the item and makes it non-selectable and non-interactive. |
| `type` | `type` | `string` | `'menuitem'` | Sets the behavior and role of the menu item, defaults to "menuitem". |
| `href` | `href` | `string` | `''` | Sets the underlying `HTMLAnchorElement`'s `href` resource attribute. |
| `download` | `download` | `string` | `''` | Sets the underlying `HTMLAnchorElement`'s `download` resource attribute. |
| `rel` | `rel` | `string` | `''` | Sets the underlying `HTMLAnchorElement`'s `rel` resource attribute. |
| `target` | `target` | `string` | `''` | Sets the underlying `HTMLAnchorElement`'s `target` attribute when `href` is set. |
| `keepOpen` | `keep-open` | `boolean` | `false` | Keeps the menu open if clicked or keyboard selected. |
| `selected` | `selected` | `boolean` | `false` | Sets the item in the selected visual state when a submenu is opened. |
Expand Down
18 changes: 18 additions & 0 deletions menu/internal/menuitem/menu-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ export class MenuItemEl extends menuItemBaseClass implements MenuItem {
*/
@property() href = '';

/**
* The filename to use when downloading the linked resource.
* If not specified, the browser will determine a filename.
* This is only applicable when the menu-item is used as a link (`href` is set).
*/
@property() download = '';

/**
* The relationship between the current document and the linked resource.
* If not specified, no `rel` attribute will be applied.
* This is only applicable when the menu-item is used as a link (`href` is set).
*/
@property() rel = '';

/**
* Sets the underlying `HTMLAnchorElement`'s `target` attribute when `href` is
* set.
Expand Down Expand Up @@ -143,6 +157,8 @@ export class MenuItemEl extends menuItemBaseClass implements MenuItem {
// TODO(b/265339866): announce "button"/"link" inside of a list item. Until
// then all are "menuitem" roles for correct announcement.
const target = isAnchor && !!this.target ? this.target : nothing;
const download = isAnchor && !!this.download ? this.download : nothing;
const rel = isAnchor && !!this.rel ? this.rel : nothing;
return staticHtml`
<${tag}
id="item"
Expand All @@ -155,6 +171,8 @@ export class MenuItemEl extends menuItemBaseClass implements MenuItem {
aria-haspopup=${(this as ARIAMixinStrict).ariaHasPopup || nothing}
class="list-item ${classMap(this.getRenderClasses())}"
href=${this.href || nothing}
download=${download}
rel=${rel}
target=${target}
@click=${this.menuItemController.onClick}
@keydown=${this.menuItemController.onKeydown}
Expand Down