mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 18:42:45 +08: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;
|
||||
article = articles[newIndex];
|
||||
|
||||
// Element doesn't exist
|
||||
if (!article) {
|
||||
// Element doesn't exist
|
||||
return;
|
||||
} else if (article.offsetParent !== null) {
|
||||
// Element is not hidden
|
||||
}
|
||||
|
||||
// Element is visible
|
||||
if (article.getBoundingClientRect().height > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,8 +72,12 @@ acceptance("Keyboard Shortcuts - Anonymous Users", function (needs) {
|
|||
|
||||
test("j/k navigation skips hidden elements", async function (assert) {
|
||||
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");
|
||||
assert
|
||||
|
|
Loading…
Reference in New Issue
Block a user