-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Retain focus for persisted input elements during view transitions (
#8813) * add new e2e test: persist focus on transition * save and restore focus during swap --------- Co-authored-by: Nate Moore <[email protected]>
- Loading branch information
1 parent
0abff97
commit 3bef32f
Showing
7 changed files
with
93 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Save and restore focus for persisted input elements during view transitions |
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
20 changes: 20 additions & 0 deletions
20
packages/astro/e2e/fixtures/view-transitions/src/pages/page-with-persistent-form.astro
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,20 @@ | ||
--- | ||
import Layout from '../components/Layout.astro'; | ||
--- | ||
<Layout> | ||
<h2>Form 1</h2> | ||
<form transition:persist> | ||
<input id="input" type="text" name="name" autocomplete="false"/> | ||
</form> | ||
|
||
<script> | ||
import {navigate} from "astro:transitions/client" | ||
const form = document.querySelector("form"); | ||
form.addEventListener("submit", (e) => { | ||
console.log("submit"); | ||
e.preventDefault(); | ||
navigate(`${location.pathname}?name=${input.value}`,{history: "replace"}); | ||
return false; | ||
}); | ||
</script> | ||
</Layout> |
3 changes: 2 additions & 1 deletion
3
packages/astro/e2e/fixtures/view-transitions/src/pages/query.astro
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