Closed jarlah closed 4 years ago
I think a hack would be to reinit the NavBar when i click a link. But is it a good work around ? Nope
it actually works wonderful (the hack), but shall I give it a try to suggest a better way for how to handle this?
The "hack":
( ClickedLink urlRequest, _ ) ->
case urlRequest of
Browser.Internal url ->
case url.fragment of
Just _ ->
-- If we got a link that included a fragment,
-- we ignore this url change, because we dont care about hash urls
( model, Cmd.none )
Nothing ->
let
( newNavState, newNavCmd ) =
Navbar.initialState NavbarMsg
in
( { model | navState = newNavState }
, Cmd.batch [ newNavCmd, Nav.pushUrl (Session.navKey (toSession model.page)) (Url.toString url) ]
)
Browser.External href ->
( model
, Nav.load href
)
Standard setup. When clicking NavBar item. New page is displayed But NavBar is still expanded. Is this NavBar only meant for like Elm apps where page is initialized on page load ?