Browse Source

focus for chat changes

master
Konstantyn Pahsura 8 years ago
parent
commit
a67087b6de
1 changed files with 8 additions and 9 deletions
  1. 8
    9
      modules/UI/side_pannels/chat/Chat.js

+ 8
- 9
modules/UI/side_pannels/chat/Chat.js View File

@@ -157,6 +157,11 @@ function resizeChatConversation() {
157 157
     chat.height(window.innerHeight - 15 - msgareaHeight);
158 158
 }
159 159
 
160
+function deferredFocus(id){
161
+    setTimeout(function (){
162
+        $(`#${id}`).focus();
163
+    }, 400);
164
+}
160 165
 /**
161 166
  * Chat related user interface.
162 167
  */
@@ -180,6 +185,7 @@ var Chat = {
180 185
                 let val = this.value;
181 186
                 this.value = '';
182 187
                 eventEmitter.emit(UIEvents.NICKNAME_CHANGED, val);
188
+                deferredFocus('usermsg');
183 189
             }
184 190
         });
185 191
 
@@ -223,9 +229,9 @@ var Chat = {
223 229
                 // if we are in conversation mode focus on the text input
224 230
                 // if we are not, focus on the display name input
225 231
                 if (APP.settings.getDisplayName())
226
-                    $('#usermsg').focus();
232
+                    deferredFocus('usermsg');
227 233
                 else
228
-                    $('#nickinput').focus();
234
+                    deferredFocus('nickinput');
229 235
             });
230 236
 
231 237
         addSmileys();
@@ -318,13 +324,6 @@ var Chat = {
318 324
     setChatConversationMode (isConversationMode) {
319 325
         $('#' + CHAT_CONTAINER_ID)
320 326
             .toggleClass('is-conversation-mode', isConversationMode);
321
-
322
-        // this is needed when we transition from no conversation mode to
323
-        // conversation mode. When user enters his nickname and hits enter,
324
-        // to focus on the write area.
325
-        if (isConversationMode) {
326
-            $('#usermsg').focus();
327
-        }
328 327
     },
329 328
 
330 329
     /**

Loading…
Cancel
Save