From 169b8021b337e4e906e9a7c8b12da930fd4e0679 Mon Sep 17 00:00:00 2001 From: paladox Date: Fri, 29 Aug 2025 20:20:35 +0100 Subject: [PATCH 1/3] feat(menu): Add support for download/rel attributes in menu-item Only works if using a link. We use these attributes at gerrit. I found a workaround for now but preferably native support should be added to menu-item. --- menu/internal/menuitem/menu-item.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/menu/internal/menuitem/menu-item.ts b/menu/internal/menuitem/menu-item.ts index 073308da51..585bc83469 100644 --- a/menu/internal/menuitem/menu-item.ts +++ b/menu/internal/menuitem/menu-item.ts @@ -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. @@ -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.donwload : nothing; + const rel = isAnchor && !!this.rel ? this.rel : nothing; return staticHtml` <${tag} id="item" @@ -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} From 8c3ade8b8233399c9edc5b3b003a55ac4573ffaf Mon Sep 17 00:00:00 2001 From: paladox Date: Fri, 29 Aug 2025 20:22:21 +0100 Subject: [PATCH 2/3] Update menu.md --- docs/components/menu.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/components/menu.md b/docs/components/menu.md index 32bacf4a55..e067d112e3 100644 --- a/docs/components/menu.md +++ b/docs/components/menu.md @@ -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. | From 210ee0ce6dea1e6f0f85e690960922561e237487 Mon Sep 17 00:00:00 2001 From: paladox Date: Tue, 9 Sep 2025 22:01:14 +0100 Subject: [PATCH 3/3] Update menu-item.ts --- menu/internal/menuitem/menu-item.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/internal/menuitem/menu-item.ts b/menu/internal/menuitem/menu-item.ts index 585bc83469..7870901baa 100644 --- a/menu/internal/menuitem/menu-item.ts +++ b/menu/internal/menuitem/menu-item.ts @@ -157,7 +157,7 @@ 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.donwload : nothing; + const download = isAnchor && !!this.download ? this.download : nothing; const rel = isAnchor && !!this.rel ? this.rel : nothing; return staticHtml` <${tag}