-
-
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.
Fixes an issue with persisted non-text input fields that have the foc…
…us during view transition navigation.
- Loading branch information
Showing
5 changed files
with
67 additions
and
2 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 | ||
--- | ||
|
||
Fixes an issue with persisted non-text input fields that have the focus during view transition navigation. |
26 changes: 26 additions & 0 deletions
26
packages/astro/e2e/fixtures/view-transitions/src/pages/persist-1.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,26 @@ | ||
--- | ||
import Layout from '../components/Layout.astro'; | ||
--- | ||
<Layout> | ||
<p id="one">Persist 1</p> | ||
<form transition:persist="form" action="/persist-2"> | ||
<input type="text" name="name" /> | ||
<input type="checkbox" /> | ||
</form> | ||
<div id="test">test content</div> | ||
</Layout> | ||
<script> | ||
const input = document.querySelector<HTMLInputElement>("form input")!; | ||
input.focus(); | ||
input.value = "some cool text"; | ||
input.selectionStart=5; | ||
input.selectionEnd=9; | ||
|
||
document.addEventListener('astro:after-swap', () => { | ||
const textInput = document.querySelector<HTMLInputElement>("form input:first-of-type")!; | ||
console.log(textInput === document.activeElement, textInput.value, textInput.selectionStart, textInput.selectionEnd); | ||
const checkBox = document.querySelector<HTMLInputElement>("form input:nth-of-type(2)")!; | ||
checkBox.checked = true; | ||
checkBox.focus(); | ||
}, {once:true}); | ||
</script> |
17 changes: 17 additions & 0 deletions
17
packages/astro/e2e/fixtures/view-transitions/src/pages/persist-2.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,17 @@ | ||
--- | ||
import Layout from '../components/Layout.astro'; | ||
--- | ||
<Layout> | ||
<p id="two">Persist 2</p> | ||
<a id="click-persist-one" href="/persist-1">go to 3</a> | ||
<div transition:persist="form"/> | ||
<div id="test">test content</div> | ||
</Layout> | ||
<script> | ||
document.addEventListener('astro:after-swap', () => { | ||
const checkBox = document.querySelector<HTMLInputElement>("form input:nth-of-type(2)")!; | ||
console.log(checkBox === document.activeElement, checkBox.checked); | ||
}, {once:true}); | ||
</script> | ||
|
||
|
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