mirror of
https://github.com/discourse/discourse.git
synced 2025-02-05 19:11:13 +00:00
DEV: Fix flakyness of keyboard navigation (#22721)
1. in the test, hiding is now done with css so if element gets rerendered it won't lose the styling 2. the skipping now allows for the `<article>` element itself being hidden
This commit is contained in:
parent
a53e900671
commit
b65b452330
@ -733,11 +733,13 @@ export default {
|
|||||||
newIndex += direction;
|
newIndex += direction;
|
||||||
article = articles[newIndex];
|
article = articles[newIndex];
|
||||||
|
|
||||||
if (!article) {
|
|
||||||
// Element doesn't exist
|
// Element doesn't exist
|
||||||
|
if (!article) {
|
||||||
return;
|
return;
|
||||||
} else if (article.offsetParent !== null) {
|
}
|
||||||
// Element is not hidden
|
|
||||||
|
// Element is visible
|
||||||
|
if (article.getBoundingClientRect().height > 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,8 +72,12 @@ acceptance("Keyboard Shortcuts - Anonymous Users", function (needs) {
|
|||||||
|
|
||||||
test("j/k navigation skips hidden elements", async function (assert) {
|
test("j/k navigation skips hidden elements", async function (assert) {
|
||||||
await visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
query("#post_2").parentElement.style = "display: none";
|
|
||||||
query("#post_3").parentElement.style = "display: none";
|
document.querySelector("#qunit-fixture").innerHTML = `
|
||||||
|
<style>
|
||||||
|
#post_2, #post_3 { display: none; }
|
||||||
|
</style>
|
||||||
|
`;
|
||||||
|
|
||||||
await triggerKeyEvent(document, "keypress", "J");
|
await triggerKeyEvent(document, "keypress", "J");
|
||||||
assert
|
assert
|
||||||
|
Loading…
x
Reference in New Issue
Block a user