From be707bfba343c2a10ee73eb2ba3a6f423315b224 Mon Sep 17 00:00:00 2001 From: Guillem Arias Fauste Date: Thu, 4 Jun 2026 22:18:47 +0200 Subject: [PATCH] =?UTF-8?q?fix(ds):=20cross-viewport=20lock=20=E2=80=94=20?= =?UTF-8?q?consistent=20auth=20mode-switch=20(#2149)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(ds): cross-viewport lock — consistent auth mode-switch (#2137) The auth sign-in/sign-up mode switch rendered as a segmented pill toggle on mobile (md:hidden) but a plain text link on desktop (hidden md:block) — the audit's cross-viewport inconsistency. Lock to the segmented switch at all widths and drop the now-redundant desktop text links. Verified on /sessions/new at desktop width: the Sign in / Create account segmented toggle now shows (was a text link). Note: the switch still uses the bespoke bg-surface-inset track; migrating it to DS::SegmentedControl (#2145) would also fix its dark-mode contrast — a follow-up once that lands. The account-new icon glyph-vs-chip case the audit grouped here did not reproduce (account_type + method_selector already use consistent DS::FilledIcon / chip icons). * fix(auth): keep the sign-in/up switch after a failed submit A failed sign-in/up POST re-renders :new from the #create action, so the switch (gated on action_name == "new") disappeared and the active tab was derived from current_page?, which breaks on the POST URL. Render the switch on both new and create, and derive the active tab from controller_name. Addresses Codex review on #2149. --- app/views/layouts/auth.html.erb | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) 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 %>