-
Notifications
You must be signed in to change notification settings - Fork 909
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 basic keyboard navigation to M3 list
PiperOrigin-RevId: 465533534
- Loading branch information
1 parent
884c3a2
commit ee35bfe
Showing
4 changed files
with
164 additions
and
4 deletions.
There are no files selected for viewing
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,38 @@ | ||
/** | ||
* @license | ||
* Copyright 2022 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import './list-item'; | ||
|
||
import {Environment} from '@material/web/testing/environment'; | ||
import {html} from 'lit'; | ||
|
||
const LIST_ITEM_TEMPLATE = html` | ||
<md-list-item>One</md-list-item> | ||
`; | ||
|
||
describe('list item tests', () => { | ||
const env = new Environment(); | ||
|
||
it('`activate()` should focus the list item', async () => { | ||
const listItem = | ||
env.render(LIST_ITEM_TEMPLATE).querySelector('md-list-item')!; | ||
await env.waitForStability(); | ||
|
||
listItem.activate(); | ||
expect(document.activeElement).toEqual(listItem); | ||
}); | ||
|
||
it('`deactivate()` should set root tab index to -1', async () => { | ||
const listItem = | ||
env.render(LIST_ITEM_TEMPLATE).querySelector('md-list-item')!; | ||
await env.waitForStability(); | ||
|
||
listItem.deactivate(); | ||
expect(listItem.shadowRoot!.querySelector('[tabindex]')!.getAttribute( | ||
'tabindex')) | ||
.toBe('-1'); | ||
}); | ||
}); |
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