From 76aeee6735ea06302dd9c09cf2bd2ce0e01e827e Mon Sep 17 00:00:00 2001 From: Osama Sayegh Date: Wed, 15 Dec 2021 02:02:31 +0300 Subject: [PATCH] A11Y: Focus last viewed topic in topic lists (#15300) --- .../discourse/app/components/topic-list-item.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/topic-list-item.js b/app/assets/javascripts/discourse/app/components/topic-list-item.js index 0fcbbd38f1..f545609487 100644 --- a/app/assets/javascripts/discourse/app/components/topic-list-item.js +++ b/app/assets/javascripts/discourse/app/components/topic-list-item.js @@ -245,12 +245,16 @@ export default Component.extend({ return; } - const $topic = $(this.element); - $topic - .addClass("highlighted") - .attr("data-islastviewedtopic", opts.isLastViewedTopic); + this.element.classList.add("highlighted"); + this.element.setAttribute( + "data-islastviewedtopic", + opts.isLastViewedTopic + ); + this.element.querySelector(".main-link .title").focus(); - $topic.on("animationend", () => $topic.removeClass("highlighted")); + this.element.addEventListener("animationend", () => { + this.element.classList.remove("highlighted"); + }); }); },