Another attempt at fixing https://meta.discourse.org/t/discourse-with-a-screen-reader/178105/88?u=osama. Previous PR (reverted): #16240. The problems with the previous PR were: 1. As you scrolled down a topics list, the first topic of every new batch of topics would receive focus and the indicator would show up. 2. Similar to 1, clicking the `See X new or updated topics` notice would also focus a random topic from the new topics that were just loaded. 3. Topics in the suggested topics list received focus too 4. Our custom focus indicator appeared on mobile, but it shouldn't. This commit should have none of these problems.
27 lines
1.0 KiB
JavaScript
27 lines
1.0 KiB
JavaScript
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
|
|
import { test } from "qunit";
|
|
import { visit } from "@ember/test-helpers";
|
|
import { cloneJSON } from "discourse-common/lib/object";
|
|
import topicFixtures from "discourse/tests/fixtures/topic";
|
|
|
|
acceptance("Last Visited Topic Focus", function (needs) {
|
|
needs.pretender((server, helper) => {
|
|
const fixture = cloneJSON(topicFixtures["/t/54077.json"]);
|
|
fixture.id = 11996;
|
|
fixture.slug =
|
|
"its-really-hard-to-navigate-the-create-topic-reply-pane-with-the-keyboard";
|
|
server.get("/t/11996.json", () => helper.response(fixture));
|
|
});
|
|
test("last visited topic receives focus when you return back to the topic list", async function (assert) {
|
|
await visit("/");
|
|
await visit(
|
|
"/t/its-really-hard-to-navigate-the-create-topic-reply-pane-with-the-keyboard/11996"
|
|
);
|
|
await visit("/");
|
|
const visitedTopicTitle = query(
|
|
'.topic-list-body tr[data-topic-id="11996"] .main-link'
|
|
);
|
|
assert.ok(visitedTopicTitle.classList.contains("focused"));
|
|
});
|
|
});
|