Skip to content

Commit

Permalink
FIX: closes chat emoji picker on body scroll (#23362)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jjaffeux committed Sep 1, 2023
1 parent 5cb45f8 commit ed35ae4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
Expand Up @@ -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);
Expand Down

This file was deleted.

Expand Up @@ -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
Expand Down

0 comments on commit ed35ae4

Please sign in to comment.