Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(list): Accept array of index for selectedIndex API #4124

Merged
merged 52 commits into from
Jan 5, 2019
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
d585757
fix(list): Auto update aria attributes based on check status
abhiomkar Nov 2, 2018
3aa9b8d
fix(list): Aria attributes to screenshot pages
abhiomkar Nov 5, 2018
db41f26
fix(list): update aria attributes based on list type
abhiomkar Nov 5, 2018
25bacc1
fix(list): Updated README
abhiomkar Nov 5, 2018
88ed948
fix(list): Updated to screenshot head > title
abhiomkar Nov 5, 2018
5a4892a
fix(list): Fix lint
abhiomkar Nov 5, 2018
5ce1753
fix(list): Updated readme to add radio, checkbox sections
abhiomkar Nov 5, 2018
b8c818c
fix(list): Update aria for only interactive lists
abhiomkar Nov 7, 2018
9d5223d
fix(list): resolve review comments.
abhiomkar Nov 9, 2018
ff65398
fix(list): Abstracted updating aria, classnames into private method f…
abhiomkar Nov 21, 2018
9ebc900
fix(list): Update code comments for preselected
abhiomkar Nov 21, 2018
0d7091e
fix(list): Updated list unit tests
abhiomkar Nov 27, 2018
73bed5a
fix(list): Updated list README
abhiomkar Nov 27, 2018
ad385e8
fix(list): Code comment
abhiomkar Nov 27, 2018
6228ab8
fix(list): fix auto toggle on label click
abhiomkar Nov 27, 2018
cb22dc9
fix(list): Review comments fix
abhiomkar Nov 28, 2018
3874baf
fix(list): Improved list foundation test coverage - 100%
abhiomkar Nov 28, 2018
da25244
fix(list): Test coverage 99.17% => 100%
abhiomkar Nov 28, 2018
5f48c2e
fix(list): Additional test for radio aria attribute change
abhiomkar Nov 28, 2018
509dbf6
fix(list): README change about tabindex
abhiomkar Nov 28, 2018
d8b4961
Merge remote-tracking branch 'origin/master' into fix/list_checkbox_aria
abhiomkar Nov 28, 2018
45f2f7d
fix(list): Updated README about checkbox role=group
abhiomkar Nov 28, 2018
57bc9f7
fix(list): trigger CBT
abhiomkar Nov 28, 2018
ca1c012
fix(list): WIP multiple selected index
abhiomkar Nov 28, 2018
19d8ad1
fix(list): Allow multiple indexes for checkbox
abhiomkar Nov 28, 2018
7420515
fix(list): merge master and resolved merge conflicts
abhiomkar Nov 28, 2018
8b9e0c9
fix(list): simplified setCheckboxAtIndex method
abhiomkar Nov 29, 2018
8ad3a30
fix(list): Fixed checkbox checked logic
abhiomkar Nov 29, 2018
f3be4a9
fix(list): Fixed unit tests, lint errors and closure tests
abhiomkar Nov 29, 2018
10460be
fix(list): Fix for review comments
abhiomkar Nov 29, 2018
8826a00
fix(list): Preselected logic for checkbox based list
abhiomkar Dec 2, 2018
18c8bb3
fix(list): Fix selectedIndex for mouse/keyboard interaction
abhiomkar Dec 3, 2018
288191e
fix(list): set tabindex to 0 when moving focus to target list item
abhiomkar Dec 3, 2018
0d9ffc5
fix(list): WIP - Fix existing unit tests.
abhiomkar Dec 3, 2018
0cfac92
fix(list): WIP - Added additional unit tests.
abhiomkar Dec 3, 2018
ab83f8f
fix(list): Set tabindex on first item when none selected on blur.
abhiomkar Dec 3, 2018
626d98a
fix(list): resolve review comments
abhiomkar Dec 4, 2018
e5664d9
fix(list): Added new unit tests and updated a thing about tabindex in…
abhiomkar Dec 4, 2018
cd220ed
fix(list): Removed programmaticSelection_ and replaced with private m…
abhiomkar Dec 6, 2018
351b5e4
fix(list): 100% test coverage for list foundation
abhiomkar Dec 6, 2018
6782e93
fix(list): 100% test coverage for list component
abhiomkar Dec 6, 2018
b30fc91
fix(list): resolve some review comments
abhiomkar Dec 8, 2018
df17474
fix(list): new unit tests for focus* methods
abhiomkar Dec 8, 2018
32ed86f
fix(list): init() => layout()
abhiomkar Dec 20, 2018
04f32d8
fix(list): README changes as per comments and updated tests
abhiomkar Jan 2, 2019
affc756
fix(list): move tabindex=0 to selected item
abhiomkar Jan 3, 2019
cd6e0ff
Merge remote-tracking branch 'origin/master' into fix/list_checkbox_s…
abhiomkar Jan 5, 2019
7370145
Merge remote-tracking branch 'origin/master' into fix/list_checkbox_s…
abhiomkar Jan 5, 2019
5389d41
fix(list): Fixed closure errors
abhiomkar Jan 5, 2019
e6a3f08
fix(list): fixed unit test for IE11
abhiomkar Jan 5, 2019
2ea1d3b
fix(list): fixed unit test for IE11
abhiomkar Jan 5, 2019
38a34de
fix(list): minor changes on self-review
abhiomkar Jan 5, 2019
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
14 changes: 9 additions & 5 deletions packages/mdc-list/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ When rendering list with checkbox items all pre-selected list items should conta
</ul>
```

The `selectedIndex` (that proxies foundation's `setSelectedState()`) accepts list of indexes in array format or single index to set the selection state. It overwrites the current state with new selected state whether it is a list of indexes or single index.

## Style Customization

### CSS Classes
Expand Down Expand Up @@ -490,6 +492,7 @@ Method Signature | Description
`hasCheckboxAtIndex(index: number) => boolean` | Returns true if checkbox is present at given list item index.
`isCheckboxCheckedAtIndex(index: number) => boolean` | Returns true if checkbox inside a list item is checked.
`setCheckedCheckboxOrRadioAtIndex(index: number, isChecked: boolean) => void` | Sets the checked status of checkbox or radio at given list item index.
`isFocusInsideList() => boolean` | Returns true if the current focused element is inside list root.

### `MDCListFoundation`

Expand All @@ -498,13 +501,14 @@ Method Signature | Description
`setWrapFocus(value: Boolean) => void` | Sets the list to allow the up arrow on the first element to focus the last element of the list and vice versa.
`setVerticalOrientation(value: Boolean) => void` | Sets the list to an orientation causing the keys used for navigation to change. `true` results in the Up/Down arrow keys being used. `false` results in the Left/Right arrow keys being used.
`setSingleSelection(value: Boolean) => void` | Sets the list to be a selection list. Enables the `enter` and `space` keys for selecting/deselecting a list item.
`setSelectedIndex(index: Number) => void` | Toggles the `selected` state of the list item at index `index`.
`getSelectedIndex() => Index` | Gets the current selection state by returning selected index or list of indexes for checkbox based list. See [constants.js](./constants.js) for `Index` type definition.
`setSelectedIndex(index: Index) => void` | Sets the selection state to given index or list of indexes if it is checkbox based list. See [constants.js](./constants.js) for `Index` type definition.
abhiomkar marked this conversation as resolved.
Show resolved Hide resolved
abhiomkar marked this conversation as resolved.
Show resolved Hide resolved
`setUseActivated(useActivated: boolean) => void` | Sets the selection logic to apply/remove the `mdc-list-item--activated` class.
`handleFocusIn(evt: Event) => void` | Handles the changing of `tabindex` to `0` for all button and anchor elements when a list item receives focus.
`handleFocusOut(evt: Event) => void` | Handles the changing of `tabindex` to `-1` for all button and anchor elements when a list item loses focus.
`handleKeydown(evt: Event) => void` | Handles determining if a focus action should occur when a key event is triggered.
`handleClick(evt: Event) => void` | Handles toggling the selected/deselected state for a list item when clicked. This method is only used by the single selection list.
`focusNextElement(index: Number) => void` | Handles focusing the next element using the current `index`.
`focusPrevElement(index: Number) => void` | Handles focusing the previous element using the current `index`.
`focusFirstElement() => void` | Handles focusing the first element in a list.
`focusLastElement() => void` | Handles focusing the last element in a list.
`focusNextElement(index: number) => number` | Handles focusing the next element using the current `index`. Returns focused element index.
`focusPrevElement(index: number) => number` | Handles focusing the previous element using the current `index`. Returns focused element index.
`focusFirstElement() => number` | Handles focusing the first element in a list. Returns focused element index.
`focusLastElement() => number` | Handles focusing the last element in a list. Returns focused element index.
5 changes: 5 additions & 0 deletions packages/mdc-list/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ class MDCListAdapter {
* @param {boolean} isChecked
*/
setCheckedCheckboxOrRadioAtIndex(index, isChecked) {}

/**
* @return {boolean} Returns true when the current focused element is inside list root.
*/
isFocusInsideList() {}
}

export default MDCListAdapter;
7 changes: 6 additions & 1 deletion packages/mdc-list/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const strings = {
ARIA_SELECTED: 'aria-selected',
ARIA_CHECKED: 'aria-checked',
ARIA_CHECKED_RADIO_SELECTOR: '[role="radio"][aria-checked="true"]',
ARIA_ROLE_CHECKBOX_SELECTOR: '[role="checkbox"]',
ARIA_CHECKED_CHECKBOX_SELECTOR: '[role="checkbox"][aria-checked="true"]',
RADIO_SELECTOR: 'input[type="radio"]:not(:disabled)',
CHECKBOX_SELECTOR: 'input[type="checkbox"]:not(:disabled)',
CHECKBOX_RADIO_SELECTOR: 'input[type="checkbox"]:not(:disabled), input[type="radio"]:not(:disabled)',
Expand All @@ -47,4 +49,7 @@ const strings = {
ENABLED_ITEMS_SELECTOR: '.mdc-list-item:not(.mdc-list-item--disabled)',
};

export {strings, cssClasses};
/** @typedef {number|!Array<number>} */
let Index;

export {strings, cssClasses, Index};
Loading