Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fragment links stop working in --debug #12

Closed
rtfeldman opened this issue Jul 26, 2018 · 0 comments
Closed

Fragment links stop working in --debug #12

rtfeldman opened this issue Jul 26, 2018 · 0 comments

Comments

@rtfeldman
Copy link
Member

The following code works fine when compiled without --debug, but once it's compiled with --debug, clicking either of the links does nothing.

SSCCE

module Main exposing (main)

import Browser exposing (Document)
import Browser.Navigation as Nav
import Html exposing (a, li, text, ul)
import Html.Attributes exposing (href)
import Time
import Url exposing (Url)


type alias Model =
    { navKey : Nav.Key
    , url : Url
    }


init : () -> Url -> Nav.Key -> ( Model, Cmd Msg )
init flags url navKey =
    ( { url = url, navKey = navKey }
    , Cmd.none
    )


view : Model -> Document Msg
view model =
    { title = "SSCCE"
    , body =
        [ text ("I think the current url is " ++ Url.toString model.url)
        , ul []
            [ li [] [ a [ href "#foo" ] [ text "#foo" ] ]
            , li [] [ a [ href "#bar" ] [ text "#bar" ] ]
            ]
        ]
    }


type Msg
    = LinkClicked Browser.UrlRequest
    | UrlChanged Url


update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
    case msg of
        LinkClicked (Browser.Internal url) ->
            ( model
            , Nav.pushUrl model.navKey (Url.toString url)
            )

        LinkClicked (Browser.External href) ->
            ( model
            , Nav.load href
            )

        UrlChanged url ->
            ( { model | url = url }, Cmd.none )


main : Program () Model Msg
main =
    Browser.application
        { init = init
        , onUrlChange = UrlChanged
        , onUrlRequest = LinkClicked
        , subscriptions = \_ -> Sub.none
        , update = update
        , view = view
        }
@evancz evancz closed this as completed in 4106168 Jul 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant