From fbde31fb1e9713a4d2fd9460664804c80f2482f9 Mon Sep 17 00:00:00 2001 From: Tyrone Yeh Date: Sat, 3 Sep 2022 21:36:27 +0800 Subject: [PATCH] Add down key check has tribute container (#21016) (#21038) Backport #21016 Fixes an issue where users would not be able to select by pressing the down arrow when using @TAG above a message Bug videos: https://user-images.githubusercontent.com/1255041/188095999-c4ccde18-e53b-4251-8a14-d90c4042d768.mp4 --- web_src/js/features/comp/EasyMDE.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/web_src/js/features/comp/EasyMDE.js b/web_src/js/features/comp/EasyMDE.js index 61aaf23e89..a739ae6c0c 100644 --- a/web_src/js/features/comp/EasyMDE.js +++ b/web_src/js/features/comp/EasyMDE.js @@ -90,6 +90,18 @@ export async function createCommentEasyMDE(textarea, easyMDEOptions = {}) { } cm.execCommand('delCharBefore'); }, + Up: (cm) => { + const tributeContainer = document.querySelector('.tribute-container'); + if (!tributeContainer || tributeContainer.style.display === 'none') { + return cm.execCommand('goLineUp'); + } + }, + Down: (cm) => { + const tributeContainer = document.querySelector('.tribute-container'); + if (!tributeContainer || tributeContainer.style.display === 'none') { + return cm.execCommand('goLineDown'); + } + }, }); attachTribute(inputField, {mentions: true, emoji: true}); attachEasyMDEToElements(easyMDE);