diff --git a/assets/js/app.js b/assets/js/app.js index 696e1ab3bf..8504626e91 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -59,6 +59,14 @@ Hooks.AlgoliaAutocomplete = { setupAlgoliaAutocomplete(this.el); } }; +Hooks.ScrollIntoView = { + // FIXME: This shouldn't need a hook; it could be implemented with + // `phx-mounted={JS.dispatch("scrollIntoView", to: #element)}` and a window + // event listener. + mounted() { + this.el.scrollIntoView({ behavior: "smooth" }); + } +}; let liveSocket = new LiveSocket("/live", Socket, { params: { _csrf_token: csrfToken }, hooks: Hooks diff --git a/lib/dotcom_web/templates/partial/_trip_planner_widget.html.eex b/lib/dotcom_web/templates/partial/_trip_planner_widget.html.eex index 237ea94ca8..ff1019c8f7 100644 --- a/lib/dotcom_web/templates/partial/_trip_planner_widget.html.eex +++ b/lib/dotcom_web/templates/partial/_trip_planner_widget.html.eex @@ -17,7 +17,7 @@ <%= if assigns[:text] do %>
<%= @text %>
<% end %> - <%= form_for @conn, "/trip-planner"<>"#plan_result_focus", form_options, fn _ -> %> + <%= form_for @conn, "/trip-planner", form_options, fn _ -> %> <%= DotcomWeb.TripPlanView.render("_to_from_inputs.html", Map.merge(assigns, %{ from_error: from_error, to_error: to_error, from_position: from_position, to_position: to_position })) %> <%= DotcomWeb.TripPlanView.render("_submit_button.html", assigns) %> <% end %> diff --git a/lib/dotcom_web/templates/trip_plan/_sidebar.html.eex b/lib/dotcom_web/templates/trip_plan/_sidebar.html.eex index cf37d47bc9..8bd68fc8d1 100644 --- a/lib/dotcom_web/templates/trip_plan/_sidebar.html.eex +++ b/lib/dotcom_web/templates/trip_plan/_sidebar.html.eex @@ -30,7 +30,7 @@ <%= render "_error.html", plan_error: plan_error %>+
<% l = length(@itineraries) %> <%= "We found #{l} #{Inflex.inflect("trip", l)} for you" %>