Skip to content

Commit

Permalink
fix(list,menu): restrict type to only supported aria roles
Browse files Browse the repository at this point in the history
## Why?

Because currently `md-list` and `md-menu` can accept any aria role as a `type` property. However this can result in invalid roles being added, e.g. `progressbar` is allowed as a valid `type`.

Instead this change scopes the `type` to the following:
 - `<md-list>` `type` can be any of: `'menu'|'menubar'|'listbox'|'list'|''`.
 - `<md-menu>` `type` can be any of: `'menu'|'menubar'|'listbox'|'list'`.

PiperOrigin-RevId: 560180446
  • Loading branch information
AndrewJakubowicz authored and copybara-github committed Aug 25, 2023
1 parent 13690a3 commit 32a8c44
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions list/internal/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import {html, LitElement, nothing} from 'lit';
import {property, query, queryAssignedElements} from 'lit/decorators.js';

import {ARIAMixinStrict, ARIARole} from '../../internal/aria/aria.js';
import {ARIAMixinStrict} from '../../internal/aria/aria.js';
import {requestUpdateOnAriaChange} from '../../internal/aria/delegate.js';

import {ListItem} from './listitem/list-item.js';
Expand Down Expand Up @@ -46,7 +46,7 @@ export class List extends LitElement {
static override shadowRootOptions:
ShadowRootInit = {mode: 'open', delegatesFocus: true};

@property() type: ARIARole|'' = 'list';
@property() type: 'menu'|'menubar'|'listbox'|'list'|'' = 'list';

/**
* The tabindex of the underlying list.
Expand Down
4 changes: 2 additions & 2 deletions menu/internal/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {eventOptions, property, query, state} from 'lit/decorators.js';
import {classMap} from 'lit/directives/class-map.js';
import {styleMap} from 'lit/directives/style-map.js';

import {ARIAMixinStrict, ARIARole} from '../../internal/aria/aria.js';
import {ARIAMixinStrict} from '../../internal/aria/aria.js';
import {requestUpdateOnAriaChange} from '../../internal/aria/delegate.js';
import {createAnimationSignal, EASING} from '../../internal/motion/animation.js';
import {List} from '../../list/internal/list.js';
Expand Down Expand Up @@ -126,7 +126,7 @@ export abstract class Menu extends LitElement {
/**
* The role of the underlying list element.
*/
@property() type: ARIARole = 'menu';
@property() type: 'menu'|'menubar'|'listbox'|'list' = 'menu';
/**
* The max time between the keystrokes of the typeahead menu behavior before
* it clears the typeahead buffer.
Expand Down

0 comments on commit 32a8c44

Please sign in to comment.