FIX: closes chat emoji picker on body scroll (#23362)

Prior to this fix we would scroll the emoji picker with the body of the page in drawer mode.

With this fix scrolling inside the drawer or the emoji picker will scroll the drawer or the emoji picker, but, scrolling body will close the chat emoji picker.
This commit is contained in:
Joffrey JAFFEUX 2023-09-01 09:17:48 +02:00 committed by GitHub
parent 5cb45f8714
commit ed35ae4dcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 7 deletions

View File

@ -3,13 +3,39 @@ import { action } from "@ember/object";
import { inject as service } from "@ember/service";
import { headerOffset } from "discourse/lib/offset-calculator";
import { createPopper } from "@popperjs/core";
import ChatEmojiPicker from "discourse/plugins/chat/discourse/components/chat-emoji-picker";
import { modifier } from "ember-modifier";
export default class ChatChannelMessageEmojiPicker extends Component {
<template>
{{! template-lint-disable modifier-name-case }}
<ChatEmojiPicker
@context="chat-channel-message"
@didInsert={{this.didInsert}}
@willDestroy={{this.willDestroy}}
@didSelectEmoji={{this.didSelectEmoji}}
@class="hidden"
{{this.listenToBodyScroll}}
/>
</template>
@service site;
@service chatEmojiPickerManager;
context = "chat-channel-message";
listenToBodyScroll = modifier(() => {
const handler = () => {
this.chatEmojiPickerManager.close();
};
document.addEventListener("scroll", handler);
return () => {
document.removeEventListener("scroll", handler);
};
});
@action
didSelectEmoji(emoji) {
this.chatEmojiPickerManager.picker?.didSelectEmoji(emoji);

View File

@ -1,7 +0,0 @@
<ChatEmojiPicker
@context="chat-channel-message"
@didInsert={{this.didInsert}}
@willDestroy={{this.willDestroy}}
@didSelectEmoji={{this.didSelectEmoji}}
@class="hidden"
/>

View File

@ -15,6 +15,7 @@
{{will-destroy (if @willDestroy @willDestroy (noop))}}
{{will-destroy this.removeClickOutsideEventListener}}
{{on "keydown" this.trapKeyDownEvents}}
...attributes
>
<div class="chat-emoji-picker__filter-container">
<DcFilterInput