FIX: emoji picker followups (#30670)

This pull request is doing the following changes:

prevents clicking on a section to scroll the document body
do not show favorites section if empty
do not close the user-status modal on emoji selection
giving its own context for user-status picker, that way if you frequently use same emojis for the picker they will always be in favorites
This commit is contained in:
Joffrey JAFFEUX 2025-01-09 14:27:48 +01:00 committed by GitHub
parent 8d3c86d984
commit b1e40d04b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 33 additions and 25 deletions

View File

@ -336,7 +336,7 @@ export default class EmojiPicker extends Component {
const targetEmoji = document.querySelector( const targetEmoji = document.querySelector(
`.emoji-picker__section[data-section="${section}"]` `.emoji-picker__section[data-section="${section}"]`
); );
targetEmoji.scrollIntoView({ block: "start" }); targetEmoji.scrollIntoView({ block: "nearest" });
// iOS hack to avoid blank div when requesting section during momentum // iOS hack to avoid blank div when requesting section during momentum
if (this.scrollableNode && this.capabilities.isIOS) { if (this.scrollableNode && this.capabilities.isIOS) {
@ -473,27 +473,29 @@ export default class EmojiPicker extends Component {
<div class="emoji-picker__content"> <div class="emoji-picker__content">
<div class="emoji-picker__sections-nav" {{this.setupSectionsNavScroll}}> <div class="emoji-picker__sections-nav" {{this.setupSectionsNavScroll}}>
{{#each-in this.groups as |section emojis|}} {{#each-in this.groups as |section emojis|}}
<DButton {{#if emojis.length}}
class={{concatClass <DButton
"btn-flat" class={{concatClass
"emoji-picker__section-btn" "btn-flat"
(if (eq this.lastVisibleSection section) "active") "emoji-picker__section-btn"
}} (if (eq this.lastVisibleSection section) "active")
tabindex="-1" }}
@action={{fn this.didRequestSection section}} tabindex="-1"
data-section={{section}} @action={{fn this.didRequestSection section}}
> data-section={{section}}
{{#if (eq section "favorites")}} >
{{replaceEmoji ":star:"}} {{#if (eq section "favorites")}}
{{else}} {{replaceEmoji ":star:"}}
<img {{else}}
width="18" <img
height="18" width="18"
class="emoji" height="18"
src={{get emojis "0.url"}} class="emoji"
/> src={{get emojis "0.url"}}
{{/if}} />
</DButton> {{/if}}
</DButton>
{{/if}}
{{/each-in}} {{/each-in}}
</div> </div>

View File

@ -21,6 +21,10 @@ export default class EmojiPicker extends Component {
return this.args.context ?? "topic"; return this.args.context ?? "topic";
} }
get modalForMobile() {
return this.args.modalForMobile ?? true;
}
<template> <template>
<DMenu <DMenu
@triggerClass={{concatClass @btnClass}} @triggerClass={{concatClass @btnClass}}
@ -28,7 +32,7 @@ export default class EmojiPicker extends Component {
@onRegisterApi={{this.onRegisterMenu}} @onRegisterApi={{this.onRegisterMenu}}
@identifier="emoji-picker" @identifier="emoji-picker"
@groupIdentifier="emoji-picker" @groupIdentifier="emoji-picker"
@modalForMobile={{true}} @modalForMobile={{this.modalForMobile}}
@maxWidth={{405}} @maxWidth={{405}}
@onShow={{@onShow}} @onShow={{@onShow}}
@onClose={{@onClose}} @onClose={{@onClose}}

View File

@ -49,6 +49,8 @@ export default class UserStatusPicker extends Component {
@icon={{@status.emoji}} @icon={{@status.emoji}}
@didSelectEmoji={{this.emojiSelected}} @didSelectEmoji={{this.emojiSelected}}
@btnClass="btn-emoji" @btnClass="btn-emoji"
@modalForMobile={{false}}
@context="user-status"
/> />
<input <input

View File

@ -26,7 +26,7 @@ module("Integration | Component | emoji-picker-content", function (hooks) {
assert assert
.dom(`.emoji-picker__section-btn.active[data-section="favorites"]`) .dom(`.emoji-picker__section-btn.active[data-section="favorites"]`)
.exists("it renders first section as active"); .exists("it renders favorites section");
assert assert
.dom(`.emoji-picker__section-btn[data-section="smileys_&_emotion"]`) .dom(`.emoji-picker__section-btn[data-section="smileys_&_emotion"]`)
.exists(); .exists();

View File

@ -13,7 +13,7 @@
flex-direction: column; flex-direction: column;
height: 300px; height: 300px;
width: 500px; width: 500px;
max-width: 100vw; max-width: 95vw;
.spinner-container { .spinner-container {
height: 100%; height: 100%;