user_status: Fix press enter to open status emoji picker.

As reported on #27270, the emoji picker in the set status modal was
not opening when pressing enter. This commit adds a keypress event
listener to the emoji picker in the set status modal, and opens the
emoji picker when the enter key is pressed.

Fixes part of #27270.
This commit is contained in:
Sayam Samal 2023-11-03 05:31:42 +05:30 committed by Tim Abbott
parent bcb7c0a65a
commit b9202ee1db
3 changed files with 13 additions and 5 deletions

View File

@ -796,10 +796,10 @@ function register_click_handlers() {
);
});
$("body").on("click", "#set-user-status-modal #selected_emoji", (e) => {
$("body").on("click", "#set-user-status-modal #selected_emoji .status-emoji-wrapper", (e) => {
e.preventDefault();
e.stopPropagation();
toggle_emoji_popover(e.target, undefined, {placement: "bottom"});
toggle_emoji_popover(e.currentTarget, undefined, {placement: "bottom"});
if (is_open()) {
// Because the emoji picker gets drawn on top of the user
// status modal, we need this hack to make clicking outside
@ -812,6 +812,12 @@ function register_click_handlers() {
}
});
$("body").on(
"keydown",
"#set-user-status-modal #selected_emoji .status-emoji-wrapper",
ui_util.convert_enter_to_click,
);
$(document).on("click", ".emoji-popover-emoji.status-emoji", function (e) {
e.preventDefault();
e.stopPropagation();

View File

@ -23,7 +23,7 @@
.status-emoji-wrapper {
padding: 4px 8px;
border-right: 1px solid;
border-color: inherit;
border-color: hsl(0deg 0% 0% / 60%);
cursor: pointer;
.selected-emoji {

View File

@ -1,6 +1,8 @@
<div class="new-style user-status-content-wrapper">
<div class="status-emoji-wrapper tippy-zulip-tooltip" data-tippy-content="{{t 'Select emoji' }}" data-tippy-placement="top" aria-label="{{t 'Select emoji' }}" tabindex="0" id="selected_emoji">
{{> status_emoji_selector}}
<div class="tippy-zulip-tooltip" data-tippy-content="{{t 'Select emoji' }}" data-tippy-placement="top" aria-label="{{t 'Select emoji' }}" id="selected_emoji">
<div class="status-emoji-wrapper" tabindex="0">
{{> status_emoji_selector}}
</div>
</div>
<input type="text" class="user-status modal_text_input" placeholder="{{t 'Your status' }}" maxlength="60"/>
<button type="button" class="btn clear_search_button" id="clear_status_message_button" disabled="disabled">