Commit Graph

140 Commits

Author SHA1 Message Date
Copybara-Service
80edf15920 Merge pull request #5229 from aarondrabeck:md-menu-color-fix
PiperOrigin-RevId: 591297433
2023-12-15 10:37:44 -08:00
Elliott Marquez
c4cbd3612c fix(menu): shift tab into anchor closes menu
PiperOrigin-RevId: 589173373
2023-12-08 10:25:43 -08:00
Material Web Team
bd88880f78 fix(menu): escape not closing menus with submenus
Ensure pressing escape while on a closed submenu anchor, closes the parent menu

Previously we were not letting a user close a menu when they were focused on any item with keepOpen = true. This included submenu anchors.

This change adds an escape (hehe) hatch to ensure that even on items with keepOpen = true, escape closes the menu. This is what most users expect and is what is the standard on menus around the web.

PiperOrigin-RevId: 587874713
2023-12-04 16:22:47 -08:00
Elliott Marquez
aafea84115 docs(menu): set target to _blank in demos
PiperOrigin-RevId: 587866823
2023-12-04 15:52:45 -08:00
Elliott Marquez
af49b64ab4 feat(menu,select): allow menu and select typeahead to read default slot text content
PiperOrigin-RevId: 587864760
2023-12-04 15:45:18 -08:00
Elizabeth Mitchell
c319236cd1 refactor: remove Firefox ARIAMixin polyfills (v119+)
This is now fixed in the latest two versions of Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1785412

PiperOrigin-RevId: 586442947
2023-11-29 13:48:38 -08:00
Aaron Drabeck
063ac88a07 fix(menu): prevent default popover color from overriding menu surface 2023-11-29 10:47:07 -07:00
Material Web Team
3d8c7ac7f3 fix(menu): declare popover property type on HTMLElement
Without it the popover property got renamed by closure.

PiperOrigin-RevId: 584184281
2023-11-20 18:53:26 -08:00
Material Web Team
bf8d3f6289 fix(menu): declare popover API types
Without it show/hide popover get renamed by closure.

PiperOrigin-RevId: 582471354
2023-11-14 16:12:59 -08:00
Elliott Marquez
2adcb1479a docs: document events in jsdoc
PiperOrigin-RevId: 581041601
2023-11-09 15:25:21 -08:00
Elliott Marquez
7859b39afe feat(menu): add popover functionality
Uses popover API for browsers that support it. Falls back to fixed positioning on browsers that do not.

fixes #2023
fixes #5120

PiperOrigin-RevId: 580633646
2023-11-08 13:14:25 -08:00
Elliott Marquez
2b591ca759 feat(menu): add document-level positioning
related #5120

PiperOrigin-RevId: 580293404
2023-11-07 14:04:00 -08:00
Elizabeth Mitchell
f5daadc307 chore: update components to use mixinFocusable
PiperOrigin-RevId: 576982507
2023-10-26 14:09:08 -07:00
Elizabeth Mitchell
c390291687 chore: format files with prettier
PiperOrigin-RevId: 576601342
2023-10-25 11:59:00 -07:00
Elliott Marquez
863109e204 fix(menu): fix menu OOB from resizing window
fixes #5063

PiperOrigin-RevId: 574286021
2023-10-17 15:42:11 -07:00
Material Web Team
4b00a9561c fix(list): list items will not escape their parent when parent width is restricted
PiperOrigin-RevId: 572988261
2023-10-12 12:59:19 -07:00
Elliott Marquez
8bbb4b4fff fix(menu): fix menu tapping behaviors on iOS and do not close on anchor click
fixes #5036
fixes #5015

iOS has some really bad behaviors when it comes to clicking and focus. clicking on the body on a non-clickable item (like anything outside a menu) does not tirgger a click event that bubbles to menu. Also, clicking on a button does not cause it to be focused, thus depriving us of information on focusout's related target. Therefore we have to assume the anchor is the trigger.

PiperOrigin-RevId: 572137765
2023-10-09 22:35:02 -07:00
Elizabeth Mitchell
c9aadeb585 chore(menu): merge HCM styles
PiperOrigin-RevId: 571239710
2023-10-05 23:28:28 -07:00
Elliott Marquez
8ae8c02866 fix(menu,select): enter clicks href items
PiperOrigin-RevId: 571104363
2023-10-05 12:55:39 -07:00
Elliott Marquez
d6f7220f0b fix(menu): fix submenu SSR left keyboard close navigation
PiperOrigin-RevId: 569664658
2023-09-29 21:44:51 -07:00
Elliott Marquez
c346f5b977 build: visibility changes
PiperOrigin-RevId: 569032710
2023-09-27 19:46:00 -07:00
Elliott Marquez
73eb15ebee fix(menu): fix menu item fade in order animation
fixes #5014

PiperOrigin-RevId: 568949388
2023-09-27 13:47:41 -07:00
Elliott Marquez
d27ef2e059 fix(menu): expose item custom properties and fix selected color
PiperOrigin-RevId: 568344744
2023-09-25 15:47:19 -07:00
Elizabeth Mitchell
682a39c480 chore(menu): update demo a11y
PiperOrigin-RevId: 568337321
2023-09-25 15:16:42 -07:00
Elliott Marquez
aeb5103e1c fix(menu,select): fix final aria issues
PiperOrigin-RevId: 568326002
2023-09-25 14:31:52 -07:00
Elliott Marquez
6d0c7e8538 refactor(list)!: refactor list to reuse ListController
fixes #4967

also fixes list-root focus ring and focusout

BREAKING CHANGE: the new ListController behavior no longer waits for event.preventDefault asynchronously because it was causing keyboard navigations to scroll the page.

PiperOrigin-RevId: 568300155
2023-09-25 12:54:12 -07:00
Elliott Marquez
5e4434bfed fix(select): update select docs and fix initial selection
PiperOrigin-RevId: 567884899
2023-09-23 11:14:56 -07:00
Elliott Marquez
f81ce1131b refactor(select): refactor select so that it doesn't rely on menuitem & use logic controller
PiperOrigin-RevId: 567735675
2023-09-22 15:45:50 -07:00
Elizabeth Mitchell
b35212a9ac feat(items): add <md-item> to @material/web/labs
PiperOrigin-RevId: 567734991
2023-09-22 15:42:42 -07:00
Elliott Marquez
5fad4f088f feat(menu): create a Menu interface for easier md-menu wrapping
PiperOrigin-RevId: 567728911
2023-09-22 15:15:41 -07:00
Elliott Marquez
1217b62ef2 refactor(menu)!: pull logic out of menuitem into a controller & change enum vals
BREAKING CHANGE: Several enums in menu had their values changed from SCREAM_CASE to kebab-case to follow style guide. They are NAVIGABLE_KEYS -> NavigableKey, SELECTION_KEY -> SelectionKey, CLOSE_REASON -> CloseReason, KEYDOWN_CLOSE_KEY -> KeydownCloseKey

PiperOrigin-RevId: 567727434
2023-09-22 15:09:41 -07:00
Elliott Marquez
63b01425e7 refactor(menu,select)!: rename fixed to positioning
This will enable forwards compatibility for `positioning="top-layer"` with popover.

BREAKING CHANGE: refactor `fixed` property to `positioning="fixed"` in Menu and `menuFixed` to `menuPositioning="fixed"`

PiperOrigin-RevId: 567723646
2023-09-22 14:54:57 -07:00
Elliott Marquez
2a1d8776a7 refactor(menu)!: refactor menu-item to use md-item and not rely on md-list-item
BREAKING CHANGE: This change refactors menu-item to no longer subclass or import from list-item. It also refactors it to use md-item directly which means that the API of menu item has moved from properties to slots. `start-*` and `end-*` slots are now just `start` and `end`, many tokens are now gone in favor of slotting. `headline` property is now a `slot="headline"` slot. Typeahead search text can now be set via `typeaheadText` which defaults to the slotted headline `textContent`. `select-option` now has the `displayText` which is used to display text in the `md-select` when the option is selected; defaults to the slotted headline `textContent`.

PiperOrigin-RevId: 567719483
2023-09-22 14:35:46 -07:00
Elliott Marquez
d6cbf74137 refactor(menu)!: remove sub-menu-item in favor of sub-menu
BREAKING CHANGE: We have deleted `md-sub-menu-item`. Instead it is recommended to use `md-sub-menu` which can have `md-menu-item[slot=item]` and `md-menu[slot=menu]` slotted into it. This makes `sub-menu-item` accessible for screen readers using linear navigation

PiperOrigin-RevId: 567706398
2023-09-22 13:41:43 -07:00
Elliott Marquez
0384507447 refactor(menu)!: update menu to use host-aria
BREAKING CHANGE: Menu no longer uses md-list internally which means the list-related properties such as `list-tabindex` and `type` should now be on the host of md-menu. The new attributes should be `tabindex` and `role` respectively.

PiperOrigin-RevId: 567702229
2023-09-22 13:24:21 -07:00
Elliott Marquez
c7c276fdfa feat(menu): do not close menu if anchor is clicked
PiperOrigin-RevId: 567096832
2023-09-20 15:25:03 -07:00
Elliott Marquez
54fbb2ed5e feat(menu): implement md-sub-menu
md-sub-menu will succeed md-sub-menu-item. It allows for screen reader linear navigation

PiperOrigin-RevId: 567057310
2023-09-20 13:09:44 -07:00
Elliott Marquez
9f3e55d79a docs: auto-generate API docs
Updates API docs in our markdown files with Lit Analyzer by manually running `npm run update-docs`

COPYBARA_INTEGRATE_REVIEW=https://github.com/material-components/material-web/pull/4946 from material-components:api-docs 1322ca962041a4b1f30ef7ad3ef2c7eb9087f42b
PiperOrigin-RevId: 566834596
2023-09-19 21:05:47 -07:00
Elliott Marquez
6e54048f1e refactor(menu)!: rename corner and focus state values lowercase with dashes
BREAKING: for style guide enum consistency, we have renamed the corner values START_START etc. to be lowercase with dashes. e.g. start-start. The same has been done with MdMenu.defaultFocus' values.
PiperOrigin-RevId: 566454879
2023-09-18 17:09:17 -07:00
Elizabeth Mitchell
94b5c8125e feat(menu): update tokens to v0.192
- Adds `--md-menu-item-selected-label-text-color` token

BREAKING CHANGE: menu selected container color changed to secondary-container

PiperOrigin-RevId: 565807703
2023-09-15 16:35:25 -07:00
Elliott Marquez
9447ec7d72 refactor(list)!: move list aria to host
BREAKING CHANGE: Aria and roles on List have been moved to the host element. list-tabindex attribute should be migrated to tabindex attribute. type attribute should be migrated to role attribute.

PiperOrigin-RevId: 565767899
2023-09-15 13:45:32 -07:00
Elliott Marquez
af171df086 fix(list,menu): clicking items in a list followed by keyboard nav functions as expected
PiperOrigin-RevId: 565539367
2023-09-14 18:59:35 -07:00
Elliott Marquez
ed689952dd feat(list,menu,select): add slots for specific slotted variants
PiperOrigin-RevId: 565536994
2023-09-14 18:42:43 -07:00
Elliott Marquez
d4463154cc refactor(list,menu,select)!: remove active concept and now parent controls tabIndex and focus
Note: tests have changed significantly because there is no longer a concept of "nothing activated" in the list.

BREAKING CHANGE: removed `active` from list-item, menu-item, and select-option. Instead, List uses tabindex to track whether something is focusable.

PiperOrigin-RevId: 565531998
2023-09-14 18:14:59 -07:00
Elliott Marquez
fad6104391 fix(list,menu): list items left right keyboard navigation
PiperOrigin-RevId: 565526741
2023-09-14 17:47:55 -07:00
Elliott Marquez
df52d92724 fix(menu): apply padding to dividers per spec
PiperOrigin-RevId: 565245411
2023-09-13 21:09:00 -07:00
Elliott Marquez
2927245114 fix(menu): menu's default focus behavior follows google accessibility practices
default focus is now FIRST_ITEM and instead of LIST_ROOT and the menu / list itself has tabindex -1 by default as our a11y model recommends

PiperOrigin-RevId: 565244488
2023-09-13 21:02:33 -07:00
Elizabeth Mitchell
573caaee1b fix(select)!: don't reflect selected attribute
Why? This is needed for selects in forms, which uses the `selected` attribute to indicate default selected values when resetting.

BREAKING CHANGE: `option.selected` no longer reflects. Set the attribute instead if relying on the attribute for styles/queries.

PiperOrigin-RevId: 565212026
2023-09-13 17:51:17 -07:00
Material Web Team
556e6f95e4 chore: fix closure compiler issues
PiperOrigin-RevId: 564867173
2023-09-12 16:30:19 -07:00
Elliott Marquez
8e79da6f41 docs(menu): lessen indirection code reuse in stories
PiperOrigin-RevId: 563544292
2023-09-07 14:21:40 -07:00