From 347669ef044deaf2d850cb0f2ae11fb8011ac0cd Mon Sep 17 00:00:00 2001 From: Jeff Wong Date: Wed, 8 Dec 2021 21:38:25 -1000 Subject: [PATCH] DEV: Add keyboard:move selection event (#15241) allows plugin event hook for keyboard:move-selection. Passes raw selected and all articles through named params. --- .../javascripts/discourse/app/lib/keyboard-shortcuts.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js b/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js index f3bd4367c37..bf572e0eaab 100644 --- a/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js +++ b/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js @@ -682,6 +682,10 @@ export default { if ($article.length > 0) { $articles.removeClass("selected"); $article.addClass("selected"); + this.appEvents.trigger("keyboard:move-selection", { + articles: $articles.get(), + selectedArticle: $article.get(0), + }); const articleRect = $article[0].getBoundingClientRect(); if (!fast && direction < 0 && articleRect.height > window.innerHeight) {