-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* reset focus properly on navigation (#307) * fix
- Loading branch information
Rich Harris
authored
Jan 7, 2021
1 parent
e09b6be
commit 72da270
Showing
7 changed files
with
48 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
Reset focus properly |
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,3 @@ | ||
<nav><a href="/focus/a">a</a> <a href="/focus/b">b</a></nav> | ||
|
||
<slot /> |
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,21 @@ | ||
import * as assert from 'uvu/assert'; | ||
|
||
export default function (test) { | ||
test('resets focus', async ({ visit, click, keyboard, evaluate, contains }) => { | ||
await visit('/focus/a'); | ||
|
||
await click('[href="/focus/b"]'); | ||
assert.ok(await contains('b')); | ||
assert.equal(await evaluate(() => document.activeElement.nodeName), 'BODY'); | ||
await keyboard.press('Tab'); | ||
assert.equal(await evaluate(() => document.activeElement.nodeName), 'A'); | ||
assert.equal(await evaluate(() => document.activeElement.textContent), 'a'); | ||
|
||
await click('[href="/focus/a"]'); | ||
assert.ok(await contains('a')); | ||
assert.equal(await evaluate(() => document.activeElement.nodeName), 'BODY'); | ||
await keyboard.press('Tab'); | ||
assert.equal(await evaluate(() => document.activeElement.nodeName), 'A'); | ||
assert.equal(await evaluate(() => document.activeElement.textContent), 'a'); | ||
}); | ||
} |
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 @@ | ||
<p>a</p> |
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 @@ | ||
<p>b</p> |
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