From 88888642f7e667cda4e28e2c72fc36c3f7c386ec Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Sat, 11 Jan 2025 00:40:47 +0100 Subject: [PATCH] FIX: correctly position emoji picker when clicking more (#30724) --- .../discourse/app/components/d-editor.js | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/d-editor.js b/app/assets/javascripts/discourse/app/components/d-editor.js index 13a106d11e7..789bbab3abc 100644 --- a/app/assets/javascripts/discourse/app/components/d-editor.js +++ b/app/assets/javascripts/discourse/app/components/d-editor.js @@ -346,7 +346,7 @@ export default class DEditor extends Component { } }, - transformComplete: (v) => { + transformComplete: (v, event) => { if (v.code) { this.emojiStore.trackEmojiForContext(v.code, "topic"); return `${v.code}:`; @@ -365,7 +365,26 @@ export default class DEditor extends Component { }, }; - const virtualElement = virtualElementFromTextRange(); + let virtualElement; + if (event instanceof KeyboardEvent) { + // when user selects more by pressing enter + virtualElement = virtualElementFromTextRange(); + } else { + // when user selects more by clicking on it + virtualElement = { + getBoundingClientRect: () => ({ + x: event.pageX, + y: event.pageY, + top: event.pageY, + left: event.pageX, + bottom: 0, + right: 0, + width: 0, + height: 0, + }), + }; + } + this.menuInstance = this.menu.show(virtualElement, menuOptions); return ""; }