From 2b399a78c86ead0afb35b9dedab6b11255881488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 29 Mar 2026 17:30:50 +0200 Subject: Focus message input when selecting conversation --- src/Main.hs | 6 ++++++ 1 file changed, 6 insertions(+) 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 -- cgit v1.2.3