-
Notifications
You must be signed in to change notification settings - Fork 667
Open
elm/virtual-dom
#187Description
Quick Summary: I have a message that should not be able to exist with my Msg type when I use the elm debugger
SSCCE
dependecies:
- aforemny/material-components-web-elm
index.html:
<!DOCTYPE HTML>
<html>
<head>
<script src="https://unpkg.com/[email protected]/dist/material-components-web-elm.min.js"></script>
<script src="elm.js"></script>
</head>
<body>
<app></app>
<script>
const app = Elm.Main.init({node: document.querySelector('app')});
</script>
</body>
</html>
src/Main.elm:
module Main exposing (main)
import Browser
import Html exposing (Html, button, div, text)
import Html.Events exposing (onClick)
import Material.Menu as Menu exposing (menuConfig)
main : Program () Model Msg
main =
Browser.sandbox
{ init = init
, update = update
, view = view
}
type Msg
= MsgPage1 Page1SubMsg
| MsgPage2 Page2SubMsg
type Page1SubMsg
= GoToPage2
| MenuClosed
type Page2SubMsg
= Page2SubMsg
type Model
= Page1
| Page2 String
init : Model
init =
Page1
update : Msg -> Model -> Model
update msg model =
case msg of
MsgPage1 GoToPage2 ->
Page2 "page 2"
MsgPage1 MenuClosed ->
model
MsgPage2 Page2SubMsg ->
Page2 "This message should never be displayed"
view : Model -> Html Msg
view model =
case model of
Page1 ->
viewPage1 |> Html.map MsgPage1
Page2 string ->
viewPage2 string |> Html.map MsgPage2
viewPage1 : Html Page1SubMsg
viewPage1 =
div []
[ Menu.menu { menuConfig | onClose = Just MenuClosed } []
, button [ onClick GoToPage2 ] [ text "test" ]
]
viewPage2 : String -> Html Page2SubMsg
viewPage2 string =
text string
- Elm: 0.19.1
- Browser: Firefox 73.0.1
- Operating System: Linux
Additional Details
step to reproduce
- Open the debugger
- Click on the "test" button: The text "page 2" is displayed on the page and the message "MsgPage1 GoToPage2" appear on the left panel of the debugger
- Click on the message "MsgPage1 GoToPage2" on the debugger: a message "MsgPage2 MenuClosed" appear on the left panel on the debugger
The message "MsgPage2 MenuClosed" doesn't match anything in the type Msg defined in file src/Main.elm
debugger export
davnn, ragnaroh, margingrotle, oyshol and thomasin
Metadata
Metadata
Assignees
Labels
No labels