From afefa32fdc07b5586f258b4d216b94f17b0e6739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Wed, 25 Mar 2026 19:54:08 +0100 Subject: Properly deselect content when clearing the url hash value --- src/Main.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Main.hs b/src/Main.hs index db1d8ef..cc6a5c6 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -379,7 +379,13 @@ processUrlParams gs@GlobalState {..} server = do | otherwise -> do JS.consoleLog $ "Unrecognized URL parameters: " <> show params - _ -> return () + _ -> do + modifyMVar_ currentContextVar $ \_ -> do + mapM_ (flip js_classList_remove (toJSString "selected")) =<< + JS.documentQuerySelector "#sidebar ul li.selected" + mapM_ (\body -> js_removeAttribute body (toJSString "data-selected")) =<< + JS.getElementById "body" + return NoContext watchIdentityUpdates :: GlobalState -> IO () @@ -667,6 +673,9 @@ foreign import javascript unsafe "$1.remove()" foreign import javascript unsafe "$1.setAttribute($2, $3)" js_setAttribute :: JSVal -> JSString -> JSString -> IO () +foreign import javascript unsafe "$1.removeAttribute($2)" + js_removeAttribute :: JSVal -> JSString -> IO () + foreign import javascript unsafe "$1.classList.add($2)" js_classList_add :: JSVal -> JSString -> IO () -- cgit v1.2.3