Skip to content

Commit

Permalink
Include query params in page navigations.
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonkearns committed Sep 7, 2023
1 parent 36ccccf commit 84f5982
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
9 changes: 8 additions & 1 deletion examples/end-to-end/app/Route/Index.elm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import FatalError exposing (FatalError)
import Head
import Head.Seo as Seo
import Html.Styled exposing (a, div, text)
import Html.Styled.Attributes as Attr
import Html.Styled.Attributes as Attr exposing (href)
import Json.Decode as Decode
import Json.Encode as Encode
import Pages.PageUrl exposing (PageUrl)
Expand Down Expand Up @@ -101,6 +101,13 @@ view app shared =
, div [] [ text <| "Greeting: " ++ app.data.greeting ]
, div [] [ text <| "Greeting: " ++ app.data.portGreeting ]
, div [] [ text <| "Random Data: " ++ Debug.toString app.data.randomTuple ]
, div []
[ a
[ href "/get-form?page=2"
]
[ text "Page 2"
]
]
, div []
[ text <|
"Now: "
Expand Down
5 changes: 5 additions & 0 deletions examples/end-to-end/cypress/e2e/get-forms.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ context("dev server with base path", () => {
cy.contains("Page 2").click();
cy.contains("Current page: 2");
});
it("navigates to a page with query params from a different starting path", () => {
cy.visit("/");
cy.contains("Page 2").click();
cy.contains("Current page: 2");
});
});
4 changes: 2 additions & 2 deletions src/Pages/Internal/Platform.elm
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ update config appMsg model =
let
navigatingToSamePage : Bool
navigatingToSamePage =
url.path == model.url.path
url.path == model.url.path && url.query == model.url.query
in
if navigatingToSamePage then
-- this is a workaround for an issue with anchor fragment navigation
Expand All @@ -403,7 +403,7 @@ update config appMsg model =

else
( model
, BrowserPushUrl url.path
, BrowserPushUrl (Url.toString url)
)

Browser.External href ->
Expand Down

0 comments on commit 84f5982

Please sign in to comment.