FIX: correctly position emoji picker when clicking more (#30724)

This commit is contained in:
Joffrey JAFFEUX 2025-01-11 00:40:47 +01:00 committed by GitHub
parent 066ece95eb
commit 88888642f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -346,7 +346,7 @@ export default class DEditor extends Component {
} }
}, },
transformComplete: (v) => { transformComplete: (v, event) => {
if (v.code) { if (v.code) {
this.emojiStore.trackEmojiForContext(v.code, "topic"); this.emojiStore.trackEmojiForContext(v.code, "topic");
return `${v.code}:`; 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); this.menuInstance = this.menu.show(virtualElement, menuOptions);
return ""; return "";
} }