diff --git a/app/views/layouts/auth.html.erb b/app/views/layouts/auth.html.erb index 271abef83..54d0adf51 100644 --- a/app/views/layouts/auth.html.erb +++ b/app/views/layouts/auth.html.erb @@ -7,29 +7,25 @@ <%= image_tag "logomark.svg", class: "w-16 mb-6" %>
- <% if (controller_name == "sessions" && action_name == "new") || (controller_name == "registrations" && action_name == "new") %> -
+ <% if controller_name.in?(%w[sessions registrations]) && action_name.in?(%w[new create]) %> + <%# Determine the active tab from the controller, not current_page?: + a failed POST re-renders :new from #create, where the request + path is the form target (not /sessions/new), so current_page? + would mis-highlight the switch. %> + <% on_sign_in = controller_name == "sessions" %> +
<%= link_to new_session_path, - class: "w-1/2 px-2 py-1 rounded-md text-sm text-center font-medium #{current_page?(new_session_path) ? 'bg-surface shadow-sm text-primary' : 'text-secondary'}" do %> + class: "w-1/2 px-2 py-1 rounded-md text-sm text-center font-medium #{on_sign_in ? 'bg-surface shadow-sm text-primary' : 'text-secondary'}" do %> <%= t("layouts.auth.sign_in") %> <% end %> <%= link_to new_registration_path, - class: "w-1/2 px-2 py-1 rounded-md text-sm text-center font-medium #{!current_page?(new_session_path) ? 'bg-surface shadow-sm text-primary' : 'text-secondary'}" do %> + class: "w-1/2 px-2 py-1 rounded-md text-sm text-center font-medium #{!on_sign_in ? 'bg-surface shadow-sm text-primary' : 'text-secondary'}" do %> <%= t("layouts.auth.sign_up") %> <% end %>
<% end %> - <% if controller_name == "sessions" %> - - <% elsif controller_name == "registrations" %> - - <% end %>