-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(list): Add arrow key a11y support. (#2871)
Add accessibility support for using arrow keys to navigate the list.
- Loading branch information
1 parent
3de2d40
commit 7c06e9f
Showing
11 changed files
with
1,112 additions
and
110 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* @license | ||
* Copyright 2018 Google Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* eslint no-unused-vars: [2, {"args": "none"}] */ | ||
|
||
/** | ||
* Adapter for MDC List. Provides an interface for managing focus. | ||
* | ||
* Additionally, provides type information for the adapter to the Closure | ||
* compiler. | ||
* | ||
* Implement this adapter for your framework of choice to delegate updates to | ||
* the component in your framework of choice. See architecture documentation | ||
* for more details. | ||
* https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md | ||
* | ||
* @record | ||
*/ | ||
class MDCListAdapter { | ||
/** @return {Number} */ | ||
getListItemCount() {} | ||
|
||
/** | ||
* @return {Number} */ | ||
getFocusedElementIndex() {} | ||
|
||
/** @param {Element} node */ | ||
getListItemIndex(node) {} | ||
|
||
/** | ||
* Focuses list item at the index specified. | ||
* @param {Number} ndx | ||
*/ | ||
focusItemAtIndex(ndx) {} | ||
|
||
/** | ||
* Sets the tabindex to the value specified for all button/a element children of | ||
* the list item at the index specified. | ||
* @param {Number} listItemIndex | ||
* @param {Number} tabIndexValue | ||
*/ | ||
setTabIndexForListItemChildren(listItemIndex, tabIndexValue) {} | ||
} | ||
|
||
export {MDCListAdapter}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* @license | ||
* Copyright 2018 Google Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** @enum {string} */ | ||
const cssClasses = { | ||
LIST_ITEM_CLASS: 'mdc-list-item', | ||
}; | ||
|
||
/** @enum {string} */ | ||
const strings = { | ||
ARIA_ORIENTATION: 'aria-orientation', | ||
ARIA_ORIENTATION_VERTICAL: 'vertical', | ||
FOCUSABLE_CHILD_ELEMENTS: 'button:not(:disabled), a', | ||
ITEMS_SELECTOR: '.mdc-list-item', | ||
}; | ||
|
||
export {strings, cssClasses}; |
Oops, something went wrong.