From 84412c4dcee1186313a0f16565cb931920d9eaba Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Thu, 20 Jun 2024 06:22:59 +0000 Subject: [PATCH] Only have autofocus on the form on the application search page This is so that users don't end up half way down the page when they first load the landing page which would be very weird --- app/views/_tailwind/applications/_address_search.html.erb | 2 +- app/views/_tailwind/applications/_address_search_form.html.erb | 2 +- app/views/_tailwind/applications/_address_with_results.html.erb | 2 +- app/views/_tailwind/home/index.html.erb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/_tailwind/applications/_address_search.html.erb b/app/views/_tailwind/applications/_address_search.html.erb index 32b9bf0a1..aef6a61d6 100644 --- a/app/views/_tailwind/applications/_address_search.html.erb +++ b/app/views/_tailwind/applications/_address_search.html.erb @@ -1,7 +1,7 @@ <% content_for :meta_description, Rails.configuration.planningalerts_meta_description %> <%= render Tailwind::Heading.new(tag: :h1, extra_classes: "sr-only").with_content("Search") %> -<%= render "address_search_form", q:, error: %> +<%= render "address_search_form", q:, error:, autofocus: true %> <% if error.nil? %>
diff --git a/app/views/_tailwind/applications/_address_search_form.html.erb b/app/views/_tailwind/applications/_address_search_form.html.erb index e22485fb0..929fb4e30 100644 --- a/app/views/_tailwind/applications/_address_search_form.html.erb +++ b/app/views/_tailwind/applications/_address_search_form.html.erb @@ -30,7 +30,7 @@ placeholder: "e.g. 1 Sowerby St, Goulburn, NSW 2580", class: class_names("text-xl", "text-navy", "w-full", "px-4", "py-3", "sm:py-4", "placeholder-shown:truncate", "focus:ring-4", "focus:ring-sun-yellow", "border-error-red" => error), required: "required", - autofocus: true, + autofocus:, "x-data" => "{ async initAutocomplete() { const { Autocomplete } = await google.maps.importLibrary('places'); new Autocomplete($el, {componentRestrictions: {country: 'au'}, types: ['address']})} diff --git a/app/views/_tailwind/applications/_address_with_results.html.erb b/app/views/_tailwind/applications/_address_with_results.html.erb index 37091a686..47c51c092 100644 --- a/app/views/_tailwind/applications/_address_with_results.html.erb +++ b/app/views/_tailwind/applications/_address_with_results.html.erb @@ -1,7 +1,7 @@ <% content_for :meta_description, Rails.configuration.planningalerts_meta_description %> <%= render Tailwind::Heading.new(tag: :h1, extra_classes: "sr-only").with_content("Search") %> -<%= render "address_search_form", q:, error: nil %> +<%= render "address_search_form", q:, error: nil, autofocus: false %> <%# TODO: Need a proper design for this section %> <%# TODO: When this section shows up it's not actually clear what the current search is for %> diff --git a/app/views/_tailwind/home/index.html.erb b/app/views/_tailwind/home/index.html.erb index c301a5a12..13473c5a8 100644 --- a/app/views/_tailwind/home/index.html.erb +++ b/app/views/_tailwind/home/index.html.erb @@ -1,7 +1,7 @@ <% content_for :meta_description, Rails.configuration.planningalerts_meta_description %> <%= render "banner" %> -<%= render "applications/address_search_form", q: nil, error: nil %> +<%= render "applications/address_search_form", q: nil, error: nil, autofocus: false %>
<%= render "how_it_works" %>