Opened 2 years ago

Closed 2 years ago

#6511 closed defect (fixed)

Pressing the Enter key should close the chat if nothing is typed.

Reported by: Langbart Owned by: Silier
Priority: Should Have Milestone: Alpha 26
Component: UI – In-game Keywords: simple, regression
Cc: Patch: Phab:D4621

Description

Youtuber Alistair Findlay reports an inconvenience on the current development version.

issue

Watch the video ~29min:50sec
When opening the chat window and nothing has been typed into the chat field pressing the Enter key should close the window.

elexis

[23:51:00] elexis 29:47 should be simple

Attachments (1)

Alistair_Findlay_enter.jpg (164.4 KB ) - added by Langbart 2 years ago.

Download all attachments as: .zip

Change History (4)

by Langbart, 2 years ago

Attachment: Alistair_Findlay_enter.jpg added

in reply to:  description comment:1 by Langbart, 2 years ago

elexis

[23:51:00] elexis 29:47 should be simple

Code lines that i would change:

  • binaries/data/mods/public/gui/session/chat/Chat.js

    a b  
    5959    {
    6060        if (g_Disconnected)
    6161            return;
    62 
     62        if (this.ChatWindow.isOpen() && !this.ChatWindow.chatInput.caption)
     63        {
     64            this.closePage()
     65            return;
     66        }
    6367        closeOpenDialogs();
    6468
    6569        this.ChatAddressees.select(command);

But I'm facing the same problem as #6234. Is this even solvable without touching cpp?

comment:2 by Langbart, 2 years ago

Component: Core engineUI – In-game
Keywords: regression added
Patch: Phab:D4621

IRC conversation with elexis

[01:26:26] elexis #6511 should Enter close the menu or should it be a hotkey that might or might not be assigned to Enter? the former is a JS oneliner, the other possibly C++ broken by concept
[...]
[01:30:16] Langbart chat, teamchat & privatechat hotkey should toggle the window
[01:30:30] Langbart (if nothing is typed)
[01:31:00] elexis so you cant say "that sucks" anymore in chat?
[01:31:19] elexis or "penis"
[01:31:59] Langbart right, deal with it. I see the flaw
[01:32:20] elexis so I guess it should not be the hotkey, but the confirm action should do that, so back to the JS oneliner
[01:32:48] Langbart but the cursor is in the input field. 
[01:33:28] elexis did I break that?
[01:33:33] elexis     submitChatInput()
[01:33:33] elexis         if (!text.length)
[01:33:33] elexis             return;
[01:34:28] elexis 23062, before it was
[...]
[01:35:49] elexis -function submitChatInput()
[01:35:49] elexis -       closeChat();
[01:35:50] elexis -       if (!text.length)
[01:35:50] elexis -               return;
[01:36:16] elexis in messages.js
[01:36:31] Langbart right, it did work in A23b.
[01:36:38] Langbart 😐
[01:36:59] elexis so the removal of the closeChat should be reverted
[01:37:29] elexis that took a while to be noticed
[01:37:49] elexis maybe not revert the closeChat
[01:37:59] elexis but perhaps one of the handlers should always handle
[01:38:10] elexis it seems currently all handlers ignore empty text
[01:38:35] elexis hm, no
[01:38:38] elexis cant read
[01:40:09] elexis +               this.ChatInput.registerChatSubmitHandler(executeNetworkCommand);
[01:40:09] elexis +               this.ChatInput.registerChatSubmitHandler(executeCheat);
[01:40:09] elexis +               this.ChatInput.registerChatSubmitHandler(this.submitChat.bind(this));
[01:40:09] elexis +               this.ChatInput.registerChatSubmittedHandler(this.closePage.bind(this));
[01:40:47] elexis ehm
[01:41:09] elexis the first one may only execute one handler, the first one that returns true
[01:41:24] elexis the second one performs all handlers, even if none of the first handlers returned true
[01:41:46] elexis then it should work and avoids the hardcoding, yielding easy expandability, especially for mods
[01:41:49] elexis while fixing the bug
[01:41:58] elexis the naming sucks
[01:43:32] elexis when naming sucks and one is not smart enough to find more specific names, one should add comments. I see the comments explain that already
[01:43:41] elexis so from what I see the proper patch would be to delete the early return
[01:44:47] elexis so the problem want that I deleted something that I shouldn't have deleted, I didnt delete enough! (ok I introduced the subscription functions which made the code a bit longer netto, whatever)
[01:44:56] elexis gn
[01:45:30] Langbart 😊

comment:3 by Silier, 2 years ago

Owner: set to Silier
Resolution: fixed
Status: newclosed

In 26842:

Fix chat window

Fix chat window not closing when submitting empty string introduced in rP23062
Always call submitted hanlders.

Differential revision: D4621
Fixes: #6511
Patch by: @Langbart
Comments by: @elexis

Note: See TracTickets for help on using tickets.