diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2026-03-25 19:54:08 +0100 |
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2026-03-25 21:11:26 +0100 |
| commit | afefa32fdc07b5586f258b4d216b94f17b0e6739 (patch) | |
| tree | 38d5c5b30bba54b60ec2c90cf83087fb3524f162 | |
| parent | fd0c3644c18f5bb5abfccbedd3f35a6573a30688 (diff) | |
Properly deselect content when clearing the url hash value
| -rw-r--r-- | src/Main.hs | 11 |
1 files changed, 10 insertions, 1 deletions
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 () |