-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: apply inert to outroing elements
that way they are invisible to assistive technology and can't be interacted with, which makes sense since the element is already "dead" and only transitioning out at this point closes #8445
- Loading branch information
1 parent
a40af4d
commit a61cc7a
Showing
4 changed files
with
78 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
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,28 @@ | ||
export default { | ||
async test({ assert, component, target, raf }) { | ||
// jsdom doesn't set the inert attribute, and the transition checks if it exists, so set it manually to trigger the inert logic | ||
target.querySelector('button.a').inert = false; | ||
target.querySelector('button.b').inert = false; | ||
|
||
// check and abort halfway through the outro transition | ||
component.visible = false; | ||
raf.tick(50); | ||
assert.strictEqual(target.querySelector('button.a').inert, true); | ||
assert.strictEqual(target.querySelector('button.b').inert, true); | ||
|
||
component.visible = true; | ||
assert.strictEqual(target.querySelector('button.a').inert, false); | ||
assert.strictEqual(target.querySelector('button.b').inert, false); | ||
|
||
// let it transition out completely and then back in | ||
component.visible = false; | ||
raf.tick(101); | ||
component.visible = true; | ||
raf.tick(50); | ||
assert.strictEqual(target.querySelector('button.a').inert, false); | ||
assert.strictEqual(target.querySelector('button.b').inert, false); | ||
raf.tick(51); | ||
assert.strictEqual(target.querySelector('button.a').inert, false); | ||
assert.strictEqual(target.querySelector('button.b').inert, false); | ||
} | ||
}; |
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,16 @@ | ||
<script> | ||
export let visible = true; | ||
function slide(_, params) { | ||
return params; | ||
} | ||
</script> | ||
|
||
{#if visible} | ||
<button class="a" transition:slide={{ duration: 100 }}> | ||
foo | ||
</button> | ||
<button class="b" out:slide={{ duration: 100 }}> | ||
bar | ||
</button> | ||
{/if} |