Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] unselect before navigation (#2755)
* fixes #1054. unselect all before navigating to another page. * fixes #1054. unselect all before navigating to another page. * #1054. removed unselect_all function. moved unselect logic to the renderer.js:update method. removed waitForTimeout calls from test. * #1054. reverted indents Co-authored-by: Senior <senior@dev.lan>
- Loading branch information
Showing
6 changed files
with
52 additions
and
0 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 | ||
--- | ||
|
||
remove all selection before navigating to the next page |
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
3 changes: 3 additions & 0 deletions
3
packages/kit/test/apps/basics/src/routes/selection/__layout.svelte
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="/selection/a">a</a> <a href="/selection/b">b</a></nav> | ||
|
||
<slot /> |
32 changes: 32 additions & 0 deletions
32
packages/kit/test/apps/basics/src/routes/selection/_tests.js
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,32 @@ | ||
import * as assert from 'uvu/assert'; | ||
|
||
/** @type {import('test').TestMaker} */ | ||
export default function (test) { | ||
test('reset selection', '/selection/a', async ({ page, clicknav }) => { | ||
assert.equal( | ||
await page.evaluate(() => { | ||
const range = document.createRange(); | ||
range.selectNodeContents(document.body); | ||
const selection = getSelection(); | ||
if (selection) { | ||
selection.removeAllRanges(); | ||
selection.addRange(range); | ||
return selection.rangeCount; | ||
} | ||
return 0; | ||
}), | ||
1 | ||
); | ||
await clicknav('[href="/selection/b"]'); | ||
assert.equal( | ||
await page.evaluate(() => { | ||
const selection = getSelection(); | ||
if (selection) { | ||
return selection.rangeCount; | ||
} | ||
return 1; | ||
}), | ||
0 | ||
); | ||
}); | ||
} |
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 @@ | ||
<svelte:head> | ||
<title>a</title> | ||
</svelte:head> | ||
|
||
<h1>a</h1> |
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 @@ | ||
<svelte:head> | ||
<title>b</title> | ||
</svelte:head> | ||
|
||
<h1>b</h1> |