diff options
| -rw-r--r-- | src/Main.hs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/Main.hs b/src/Main.hs index 7965516..bad0ec1 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -312,6 +312,7 @@ setup = do Nothing -> return () JS.addEventListener sendForm "submit" $ \_ -> do + js_focus sendText readMVar currentContextVar >>= \case SelectedConversation conv -> do msg <- T.pack . fromJSString <$> js_get_value sendText @@ -538,6 +539,8 @@ selectConversation gs@GlobalState {..} conv = do js_setAttribute body (toJSString "data-selected") (toJSString "conversation") Nothing -> return () + mapM_ js_focus =<< JS.getElementById "msg_text" + return $ SelectedConversation conv selectPeer :: GlobalState -> Server -> RefDigest -> IO () @@ -731,6 +734,9 @@ foreign import javascript unsafe "$1.value" foreign import javascript unsafe "$1.value = $2" js_set_value :: JSVal -> JSString -> IO () +foreign import javascript unsafe "$1.focus()" + js_focus :: JSVal -> IO () + foreign import javascript unsafe "window" js_window :: JSVal |