From b2ead4bc5a0c9095ffd23488b3f12d38c1fe471a Mon Sep 17 00:00:00 2001 From: Denis Talakevich Date: Wed, 2 Dec 2026 17:52:59 +0200 Subject: [PATCH 01/15] Readable but dimmer EMPTY placeholder in both modes In dark mode the v3 #bbb read almost like a value; in light mode ActiveAdmin's gray-400/50 was barely readable. #8a929c (4.6:1) and #8f969e (about 3:1) keep EMPTY readable and clearly dimmer than values. Co-Authored-By: Clanker --- app/tailwind/active_admin_theme.css | 9 ++++++-- test/form_look_test.rb | 32 +++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/app/tailwind/active_admin_theme.css b/app/tailwind/active_admin_theme.css index 2e5880a..de31c55 100644 --- a/app/tailwind/active_admin_theme.css +++ b/app/tailwind/active_admin_theme.css @@ -696,7 +696,12 @@ body { display: none; } -/* v3 drew EMPTY in #bbb in both modes; ActiveAdmin's dark gray-600/50 is barely readable. */ +/* ActiveAdmin's gray-400/50 and dark gray-600/50 are barely readable. These + * grays keep about 3:1 on white and 4.6:1 on the dark panel, well under values, + * so EMPTY stays readable and reads as a blank. */ +.attributes-table-empty-value { + color: #8f969e; +} .dark .attributes-table-empty-value { - color: #bbbbbb; + color: #8a929c; } diff --git a/test/form_look_test.rb b/test/form_look_test.rb index b639fb6..34102b9 100644 --- a/test/form_look_test.rb +++ b/test/form_look_test.rb @@ -42,10 +42,38 @@ def test_tabs_in_a_form_keep_their_look_in_dark_mode assert_equal "rgba(0, 0, 0, 0)", style("#form-panels .aat-panel-toggle", "backgroundColor") end - def test_empty_values_are_as_bright_as_v3_in_dark_mode + # Contrast ratio (WCAG 2) of the text of +selector+ against the first + # opaque background behind it. + def contrast(selector) + page.evaluate_script(<<~JS) + (() => { + const rgb = (value) => value.match(/[\\d.]+/g).map(Number) + const lum = ([r, g, b]) => [r, g, b].map((c) => { c /= 255; return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4 }) + .reduce((sum, c, i) => sum + c * [0.2126, 0.7152, 0.0722][i], 0) + let el = document.querySelector(#{selector.to_json}) + const fg = lum(rgb(getComputedStyle(el).color)) + while (el && (rgb(getComputedStyle(el).backgroundColor)[3] === 0)) el = el.parentElement + const bg = lum(rgb(getComputedStyle(el || document.body).backgroundColor)) + return (Math.max(fg, bg) + 0.05) / (Math.min(fg, bg) + 0.05) + })() + JS + end + + def test_empty_values_are_dimmer_than_values_but_readable_in_dark_mode visit "/admin/components" page.execute_script("document.documentElement.classList.add('dark')") - assert_equal "rgb(187, 187, 187)", style("#pre-wrap-blank .attributes-table-empty-value", "color") + empty = "#pre-wrap-blank .attributes-table-empty-value" + assert_equal "rgb(138, 146, 156)", style(empty, "color") + assert_operator contrast(empty), :>=, 4.5 + assert_operator contrast(empty), :<, contrast("#pre-wrap") / 2 + end + + def test_empty_values_are_dimmer_than_values_but_readable_in_light_mode + visit "/admin/components" + empty = "#pre-wrap-blank .attributes-table-empty-value" + assert_equal "rgb(143, 150, 158)", style(empty, "color") + assert_operator contrast(empty), :>=, 2.95 + assert_operator contrast(empty), :<, contrast("#pre-wrap") / 2 end def test_a_panel_after_the_form_actions_has_a_gap From 277844d50c462ddae2d87b6fbf25dc897488038e Mon Sep 17 00:00:00 2001 From: Denis Talakevich Date: Wed, 2 Dec 2026 17:56:40 +0200 Subject: [PATCH 02/15] Wide table_for in a tab scrolls inside the tab A table_for scrolled only when it sat right in a panel body; in a tab it ran past the panel and widened the page. Co-Authored-By: Clanker --- app/tailwind/active_admin_theme.css | 5 +++-- test/components_test.rb | 9 +++++++++ test/dummy/app/admin/components_demo.rb | 11 +++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/tailwind/active_admin_theme.css b/app/tailwind/active_admin_theme.css index de31c55..b170e87 100644 --- a/app/tailwind/active_admin_theme.css +++ b/app/tailwind/active_admin_theme.css @@ -175,8 +175,9 @@ .data-table :where(tbody > tr.selected) > td { background-color: var(--aat-selected-row); } -/* A table_for in a panel scrolls sideways instead of widening the page. */ -.panel-body:has(> .data-table) { +/* A table_for in a panel or a tab scrolls sideways instead of widening the page. */ +.panel-body:has(> .data-table), +.aat-tab-panel:has(> .data-table) { overflow-x: auto; } /* Opt-in sticky first column. Body cells keep the stripe, hover and selected fills above. */ diff --git a/test/components_test.rb b/test/components_test.rb index 7aca5cc..8633cce 100644 --- a/test/components_test.rb +++ b/test/components_test.rb @@ -53,6 +53,15 @@ def test_table_in_a_panel_scrolls_with_a_sticky_first_column assert_equal style(second, "backgroundColor"), style(first, "backgroundColor") end + def test_table_in_a_tab_scrolls_inside_the_tab + tab = "#tab-table .aat-tab-panel:not(.hidden)" + assert_equal "auto", style(tab, "overflowX") + right = ->(sel) { page.evaluate_script("document.querySelector(#{sel.to_json}).getBoundingClientRect().right") } + assert page.evaluate_script("(() => { const e = document.querySelector(#{tab.to_json}); return e.scrollWidth > e.clientWidth })()") + assert_operator right.(tab), :<=, right.("#tab-table") + assert_operator page.evaluate_script("document.documentElement.scrollWidth"), :<=, 1280 + end + def test_body_uses_the_v3_font_without_antialiasing assert_match(/\A"Helvetica Neue", Arial/, style("body", "fontFamily")) assert_equal "auto", style("body", "webkitFontSmoothing") diff --git a/test/dummy/app/admin/components_demo.rb b/test/dummy/app/admin/components_demo.rb index d5a79e2..5de9e01 100644 --- a/test/dummy/app/admin/components_demo.rb +++ b/test/dummy/app/admin/components_demo.rb @@ -55,6 +55,17 @@ end end + panel "Table in tabs", id: "tab-table" do + tabs do + tab "Wide table" do + table_for (1..2).to_a do + (1..20).each { |c| column("Column #{c}") { |r| "row #{r} / value #{c}" } } + end + end + tab("Other") { para "Another tab" } + end + end + panel "Secret reveal" do div(id: "secret") { secret_reveal url: "/admin/components/secret" } end From 563397a2ffa3e1d4b585147fd6fab77ceb465d27 Mon Sep 17 00:00:00 2001 From: Denis Talakevich Date: Wed, 2 Dec 2026 19:15:08 +0200 Subject: [PATCH 03/15] Docs: where to find theme 3 for ActiveAdmin 3 The README and the migration guide pointed to a 3.x branch that exists only on a fork. Theme 3 is 3.3.0 on RubyGems, documented at the v3.3.0 tag. Co-Authored-By: Clanker --- README.md | 7 ++++++- docs/migrating-from-v3.md | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 46d4156..7f8c618 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,12 @@ ActiveAdmin 4 keeps its menu in a left sidebar and gives breadcrumbs and titles - Index tables scroll sideways when they are wider than the screen, and cells stay on one line. - Theme 3 colors, density, and typography on top of ActiveAdmin 4's own dark mode. -Theme 4 needs ActiveAdmin 4 (`>= 4.0.0.beta23`) and Ruby 3.3 or newer. For ActiveAdmin 3, use theme 3.x (branch `3.x`). See [docs/migrating-from-v3.md](docs/migrating-from-v3.md). +Theme 4 needs ActiveAdmin 4 (`>= 4.0.0.beta23`) and Ruby 3.3 or newer. To upgrade from theme 3, see [docs/migrating-from-v3.md](docs/migrating-from-v3.md). + +| ActiveAdmin | Theme | Install | Docs | +| --- | --- | --- | --- | +| 4 | 4.0.0.beta1 | `gem "active_admin_theme", github: "activeadmin-plugins/active_admin_theme", tag: "v4.0.0.beta1"` | this README | +| 3 | 3.3.0 | `gem "active_admin_theme", "~> 3.3"` (RubyGems) | [v3.3.0 README](https://github.com/activeadmin-plugins/active_admin_theme/blob/v3.3.0/README.md) | ## Screenshots diff --git a/docs/migrating-from-v3.md b/docs/migrating-from-v3.md index ffe28af..80fa30f 100644 --- a/docs/migrating-from-v3.md +++ b/docs/migrating-from-v3.md @@ -2,7 +2,7 @@ Theme 4 is a rework for ActiveAdmin 4. ActiveAdmin 4 replaced SCSS and Sprockets with Tailwind CSS 4, ERB partials, and import maps, so theme 3 cannot run on it. On screen the result looks almost the same. In your app, a few things change. -Upgrade ActiveAdmin first, and follow ActiveAdmin's own [upgrade guide](https://github.com/activeadmin/activeadmin/blob/master/UPGRADING.md). Then switch the theme. Theme 3.x stays on the `3.x` branch and keeps getting bug fixes. +Upgrade ActiveAdmin first, and follow ActiveAdmin's own [upgrade guide](https://github.com/activeadmin/activeadmin/blob/master/UPGRADING.md). Then switch the theme. Theme 3 stays on RubyGems as 3.3.0, with its docs in the [v3.3.0 README](https://github.com/activeadmin-plugins/active_admin_theme/blob/v3.3.0/README.md). ## Checklist From 9ff918a42a89c98e85e8b52e5a7d3abe85f03dc0 Mon Sep 17 00:00:00 2001 From: Denis Talakevich Date: Wed, 2 Dec 2026 19:20:52 +0200 Subject: [PATCH 04/15] Docs: name the 3.x maintenance branch for theme 3 Co-Authored-By: Clanker --- README.md | 2 +- docs/migrating-from-v3.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7f8c618..a989715 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Theme 4 needs ActiveAdmin 4 (`>= 4.0.0.beta23`) and Ruby 3.3 or newer. To upgrad | ActiveAdmin | Theme | Install | Docs | | --- | --- | --- | --- | | 4 | 4.0.0.beta1 | `gem "active_admin_theme", github: "activeadmin-plugins/active_admin_theme", tag: "v4.0.0.beta1"` | this README | -| 3 | 3.3.0 | `gem "active_admin_theme", "~> 3.3"` (RubyGems) | [v3.3.0 README](https://github.com/activeadmin-plugins/active_admin_theme/blob/v3.3.0/README.md) | +| 3 | 3.3.0, maintained on the [`3.x`](https://github.com/activeadmin-plugins/active_admin_theme/tree/3.x) branch | `gem "active_admin_theme", "~> 3.3"` (RubyGems) | [v3.3.0 README](https://github.com/activeadmin-plugins/active_admin_theme/blob/v3.3.0/README.md) | ## Screenshots diff --git a/docs/migrating-from-v3.md b/docs/migrating-from-v3.md index 80fa30f..168cf89 100644 --- a/docs/migrating-from-v3.md +++ b/docs/migrating-from-v3.md @@ -2,7 +2,7 @@ Theme 4 is a rework for ActiveAdmin 4. ActiveAdmin 4 replaced SCSS and Sprockets with Tailwind CSS 4, ERB partials, and import maps, so theme 3 cannot run on it. On screen the result looks almost the same. In your app, a few things change. -Upgrade ActiveAdmin first, and follow ActiveAdmin's own [upgrade guide](https://github.com/activeadmin/activeadmin/blob/master/UPGRADING.md). Then switch the theme. Theme 3 stays on RubyGems as 3.3.0, with its docs in the [v3.3.0 README](https://github.com/activeadmin-plugins/active_admin_theme/blob/v3.3.0/README.md). +Upgrade ActiveAdmin first, and follow ActiveAdmin's own [upgrade guide](https://github.com/activeadmin/activeadmin/blob/master/UPGRADING.md). Then switch the theme. Theme 3 stays on RubyGems as 3.3.0, with its docs in the [v3.3.0 README](https://github.com/activeadmin-plugins/active_admin_theme/blob/v3.3.0/README.md). Theme 3 fixes go to the [`3.x`](https://github.com/activeadmin-plugins/active_admin_theme/tree/3.x) branch. ## Checklist From bdad68c29fd3f87e62bc3ada568950f7412dbcdb Mon Sep 17 00:00:00 2001 From: Denis Talakevich Date: Thu, 3 Dec 2026 14:30:33 +0200 Subject: [PATCH 05/15] Page objects: confirm dialog waits for enabled buttons A dialog can enable OK only after async content loads, and a click on the disabled button did nothing. Co-Authored-By: Clanker --- .../page_objects/confirm_dialog.rb | 19 ++++++++++----- test/page_objects_components_test.rb | 24 +++++++++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/lib/active_admin_theme/page_objects/confirm_dialog.rb b/lib/active_admin_theme/page_objects/confirm_dialog.rb index 57b3b32..57baa13 100644 --- a/lib/active_admin_theme/page_objects/confirm_dialog.rb +++ b/lib/active_admin_theme/page_objects/confirm_dialog.rb @@ -117,18 +117,20 @@ def field(locator) own ? own.find("input:not([type=hidden]), select, textarea", match: :first) : modal.find(:field, locator.to_s) end - # Clicks the confirm button, which submits the dialog's form. The - # browser keeps the dialog open while a required field is empty; - # +validate: false+ skips that check, so the server's own check runs. + # Waits for the confirm button to be enabled, then clicks it, which + # submits the dialog's form. The browser keeps the dialog open while a + # required field is empty; +validate: false+ skips that check, so the + # server's own check runs. def confirm(validate: true) - button = modal.find(:active_admin, :confirm_dialog_submit) + button = enabled_button(:confirm_dialog_submit) button.session.execute_script("arguments[0].form.noValidate = true", button) unless validate button.click end - # Clicks the cancel button and waits for the dialog to close. + # Waits for the cancel button to be enabled, clicks it, and waits for + # the dialog to close. def cancel - modal.find(:active_admin, :confirm_dialog_cancel).click + enabled_button(:confirm_dialog_cancel).click has_no_open? end @@ -138,6 +140,11 @@ def modal find(:active_admin, :confirm_dialog_modal, visible: true) end + # A dialog can enable its buttons after async content loads. + def enabled_button(key) + modal.find(:css, "#{sel(key)}:not(:disabled)") + end + def set_control(control, value) if control.tag_name == "select" Array(value).each { |text| control.select(text.to_s) } diff --git a/test/page_objects_components_test.rb b/test/page_objects_components_test.rb index 7a5bf52..9e9e1b9 100644 --- a/test/page_objects_components_test.rb +++ b/test/page_objects_components_test.rb @@ -287,4 +287,28 @@ def test_confirm_dialog_submits_with_its_method assert_raises(Capybara::Ambiguous) { dialogs.confirm_dialog } assert_equal "Suspend customer", dialogs.confirm_dialog(dialog: "action-confirm").trigger_text end + + def test_confirm_dialog_waits_for_its_buttons_to_be_enabled + dialogs = Pages::ConfirmDialogs.new + dialogs.load + dialog = dialogs.confirm_dialog("Archive customer").open + disable_buttons_for_a_while("plain-confirm") + dialog.cancel + assert dialog.has_no_open? + + dialog.open + disable_buttons_for_a_while("plain-confirm") + dialog.confirm + assert_text "POST {}" + end + + private + + def disable_buttons_for_a_while(modal_id) + page.execute_script(<<~JS, modal_id) + const buttons = document.getElementById(arguments[0]).querySelectorAll(".aat-confirm-submit, .aat-confirm-cancel"); + buttons.forEach((button) => { button.disabled = true; }); + setTimeout(() => buttons.forEach((button) => { button.disabled = false; }), 500); + JS + end end From 9a9d9f4110a74048a819342ec55ff1e9d5019342 Mon Sep 17 00:00:00 2001 From: Denis Talakevich Date: Thu, 3 Dec 2026 14:55:37 +0200 Subject: [PATCH 06/15] Login page: box only the card that holds the title The old rule boxed every childless div, so an app's empty wrapper showed as a 2px square, and it missed ActiveAdmin's stock card, which has a links div. Co-Authored-By: Clanker --- app/tailwind/active_admin_theme.css | 5 +++-- .../controllers/login_preview_controller.rb | 19 +++++++++++++++++++ test/dummy/config/routes.rb | 1 + test/form_look_test.rb | 8 ++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 test/dummy/app/controllers/login_preview_controller.rb diff --git a/app/tailwind/active_admin_theme.css b/app/tailwind/active_admin_theme.css index b170e87..7dbf8e3 100644 --- a/app/tailwind/active_admin_theme.css +++ b/app/tailwind/active_admin_theme.css @@ -422,8 +422,9 @@ table.data-table td[data-selected-cell] { overflow-x: auto; } -/* Login pages: the Devise card follows the theme surface and border. */ -[data-aat-login] > div:not(:has(> div)) { +/* Login pages: the Devise card, the box that holds the title, follows the + * theme surface and border. A host's empty wrapper gets no box. */ +[data-aat-login] > div:has(> h2) { background-color: var(--aat-surface); border: 1px solid var(--aat-border); border-radius: 0.25rem; diff --git a/test/dummy/app/controllers/login_preview_controller.rb b/test/dummy/app/controllers/login_preview_controller.rb new file mode 100644 index 0000000..660b7ff --- /dev/null +++ b/test/dummy/app/controllers/login_preview_controller.rb @@ -0,0 +1,19 @@ +# The dummy has no Devise. This page renders the theme's logged-out layout +# with ActiveAdmin's stock login card, after an empty wrapper of the host. +class LoginPreviewController < ApplicationController + layout "active_admin_logged_out" + helper ActiveAdmin::LayoutHelper + + def show + @page_title = "Login" + render layout: true, html: <<~HTML.html_safe +
+
+
+

Admin Login

+

The form goes here.

+ +
+ HTML + end +end diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb index e6277d6..3e19010 100644 --- a/test/dummy/config/routes.rb +++ b/test/dummy/config/routes.rb @@ -1,4 +1,5 @@ Rails.application.routes.draw do ActiveAdmin.routes(self) + get "login_preview", to: "login_preview#show" root to: redirect("/admin") end diff --git a/test/form_look_test.rb b/test/form_look_test.rb index 34102b9..4160e1e 100644 --- a/test/form_look_test.rb +++ b/test/form_look_test.rb @@ -76,6 +76,14 @@ def test_empty_values_are_dimmer_than_values_but_readable_in_light_mode assert_operator contrast(empty), :<, contrast("#pre-wrap") / 2 end + def test_login_card_gets_the_theme_box_and_an_empty_host_div_none + visit "/login_preview" + assert_equal "1px", style("#login-card", "borderTopWidth") + assert_equal "rgb(224, 228, 233)", style("#login-card", "borderTopColor") + assert_equal "0px", style("#host-empty-wrapper", "borderTopWidth") + assert_equal "rgba(0, 0, 0, 0)", style("#host-empty-wrapper", "backgroundColor") + end + def test_a_panel_after_the_form_actions_has_a_gap visit "/admin/form_panels" gap = rect("#form-result")[2] - rect("#form-panels [type=submit]")[3] From edddbb23d35366769ec778a44a09c9b07953106f Mon Sep 17 00:00:00 2001 From: Denis Talakevich Date: Thu, 3 Dec 2026 15:29:17 +0200 Subject: [PATCH 07/15] Header: draw the bottom border as a border The inset shadow painted under the full-height menu links, so a hovered link's highlight covered the line. Co-Authored-By: Clanker --- app/tailwind/active_admin_theme.css | 5 +++-- test/layout_test.rb | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/tailwind/active_admin_theme.css b/app/tailwind/active_admin_theme.css index 7dbf8e3..e32d34a 100644 --- a/app/tailwind/active_admin_theme.css +++ b/app/tailwind/active_admin_theme.css @@ -585,9 +585,10 @@ body { z-index: 30; gap: 0.75rem; padding: 0 0.625rem; + /* A real border, inside the fixed height, so a hovered menu link stops above it. */ border: 0; - /* An inset shadow, so the fixed header keeps its --aa-header-height. */ - box-shadow: inset 0 -1px 0 var(--aat-header-border); + border-bottom: 1px solid var(--aat-header-border); + box-shadow: none; backdrop-filter: none; background-color: var(--aat-header-bg); color: var(--aat-header-text); diff --git a/test/layout_test.rb b/test/layout_test.rb index 5937fa9..24f940e 100644 --- a/test/layout_test.rb +++ b/test/layout_test.rb @@ -15,6 +15,16 @@ def teardown Capybara.reset_sessions! end + def test_hovered_top_menu_link_stops_above_the_header_border + visit "/admin/customers" + find("#site-header nav a", text: "Demo pages").hover + header = page.evaluate_script("document.getElementById('site-header').getBoundingClientRect().toJSON()") + link = page.evaluate_script("[...document.querySelectorAll('#site-header nav > ul > li > a')].find(a => a.textContent.includes('Demo pages')).getBoundingClientRect().toJSON()") + assert_equal 40, header["height"] + assert_equal "1px", page.evaluate_script("getComputedStyle(document.getElementById('site-header')).borderBottomWidth") + assert_operator link["bottom"], :<=, header["bottom"] - 1 + end + def test_desktop_has_top_menu_and_no_drawer visit "/admin/customers" assert_selector "#site-header nav a", text: "Customers" From 481bef67434d3b375da3f4ab360a17db999aa4eb Mon Sep 17 00:00:00 2001 From: Denis Talakevich Date: Thu, 3 Dec 2026 15:30:42 +0200 Subject: [PATCH 08/15] Index: hide an empty toolbar ActiveAdmin renders the toolbar whenever a resource has batch actions, even when display_if hides them all, so its margin pushed the table below the sidebar top. CSS keeps the theme from copying index.html.arb. Co-Authored-By: Clanker --- app/tailwind/active_admin_theme.css | 7 ++++++- test/dummy/app/admin/quiet_orders.rb | 17 +++++++++++++++++ test/form_look_test.rb | 10 ++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 test/dummy/app/admin/quiet_orders.rb diff --git a/app/tailwind/active_admin_theme.css b/app/tailwind/active_admin_theme.css index e32d34a..600930c 100644 --- a/app/tailwind/active_admin_theme.css +++ b/app/tailwind/active_admin_theme.css @@ -509,7 +509,12 @@ table.data-table td[data-selected-cell] { } } -/* Index toolbar: scopes, batch actions. */ +/* Index toolbar: scopes, batch actions. ActiveAdmin renders it whenever batch + * actions exist, even when display_if hides them all; empty, its margin pushes + * the table below the sidebar top. */ +.index-data-table-toolbar:not(:has(*)) { + display: none; +} .index-button, .batch-actions-dropdown-toggle { height: 1.875rem; diff --git a/test/dummy/app/admin/quiet_orders.rb b/test/dummy/app/admin/quiet_orders.rb new file mode 100644 index 0000000..395e748 --- /dev/null +++ b/test/dummy/app/admin/quiet_orders.rb @@ -0,0 +1,17 @@ +# An index with batch actions on but none shown and no scopes: ActiveAdmin +# still renders the toolbar, empty (test/form_look_test.rb). +ActiveAdmin.register Order, as: "QuietOrder" do + menu false + config.batch_actions = true + batch_action :destroy, false + batch_action(:flag, if: proc { false }) { |_ids| redirect_to collection_path } + + filter :status, as: :select, collection: Order::STATUSES + + index do + selectable_column + id_column + column :reference + column :status + end +end diff --git a/test/form_look_test.rb b/test/form_look_test.rb index 4160e1e..4ab98b9 100644 --- a/test/form_look_test.rb +++ b/test/form_look_test.rb @@ -84,6 +84,16 @@ def test_login_card_gets_the_theme_box_and_an_empty_host_div_none assert_equal "rgba(0, 0, 0, 0)", style("#host-empty-wrapper", "backgroundColor") end + def test_index_without_toolbar_content_starts_level_with_the_sidebar + visit "/admin/quiet_orders" + assert_selector ".index-data-table-toolbar", visible: :all + assert_no_selector ".index-data-table-toolbar" + assert_in_delta rect("[data-aat-sidebar]")[2], rect(".data-table")[2], 1 + + visit "/admin/customers" + assert_selector ".index-data-table-toolbar .scopes" + end + def test_a_panel_after_the_form_actions_has_a_gap visit "/admin/form_panels" gap = rect("#form-result")[2] - rect("#form-panels [type=submit]")[3] From 8618043d9aeb6a2d53e8b1d58dad832296f65155 Mon Sep 17 00:00:00 2001 From: Denis Talakevich Date: Thu, 3 Dec 2026 15:32:19 +0200 Subject: [PATCH 09/15] Top menu: open dropdowns on hover without delay Flowbite's hover trigger opened and closed each dropdown 100 ms late. CSS :hover opens it at once, as in v3, and keyboard focus opens it too. Co-Authored-By: Clanker --- app/javascript/active_admin_theme/layout.js | 8 ++++---- app/tailwind/active_admin_theme.css | 18 ++++++++++++++++-- .../active_admin/_header_navigation.html.erb | 6 +++--- test/layout_test.rb | 15 +++++++++++++++ 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/app/javascript/active_admin_theme/layout.js b/app/javascript/active_admin_theme/layout.js index 4c7708e..31fdb7e 100644 --- a/app/javascript/active_admin_theme/layout.js +++ b/app/javascript/active_admin_theme/layout.js @@ -33,12 +33,12 @@ const init = () => apply(read()) if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", init) else init() -// A top-menu flyout that would run past the viewport edge opens on the other -// side of its item instead. +// A top-menu dropdown or flyout that would run past the viewport edge opens on +// the other side of its item instead. const placeFlyout = (event) => { - const item = event.target.closest("[data-aat-submenu]") + const item = event.target.closest("[data-aat-submenu], [data-aat-top-item]") if (!item || item.contains(event.relatedTarget)) return - const flyout = item.querySelector(":scope > .aat-flyout") + const flyout = item.querySelector(":scope > .aat-flyout, :scope > .aat-top-dropdown") if (!flyout) return item.removeAttribute("data-aat-flip") const rect = flyout.getBoundingClientRect() diff --git a/app/tailwind/active_admin_theme.css b/app/tailwind/active_admin_theme.css index 600930c..c51837e 100644 --- a/app/tailwind/active_admin_theme.css +++ b/app/tailwind/active_admin_theme.css @@ -580,8 +580,22 @@ body { } } -/* A top-menu item keeps its highlight while its dropdown is open, as in v3. */ -[data-aat-main-menu] li:has(> div:not(.hidden)) > a { +/* A top-menu dropdown opens and closes with the pointer or keyboard focus, with no + * delay, as in v3. Its item keeps the highlight while it is open. */ +.aat-top-dropdown { + display: none; + position: absolute; + top: 100%; + inset-inline-start: 0; +} +[data-aat-top-item]:is(:hover, :has(:focus-visible)) > .aat-top-dropdown { + display: block; +} +[data-aat-top-item][data-aat-flip] > .aat-top-dropdown { + inset-inline-start: auto; + inset-inline-end: 0; +} +[data-aat-top-item]:is(:hover, :has(:focus-visible)) > a { background-color: var(--aat-menu-pill); color: var(--aat-menu-hover-text); } diff --git a/app/views/active_admin/_header_navigation.html.erb b/app/views/active_admin/_header_navigation.html.erb index 67165c3..1564977 100644 --- a/app/views/active_admin/_header_navigation.html.erb +++ b/app/views/active_admin/_header_navigation.html.erb @@ -5,14 +5,14 @@ <% url = item.url(self) %> <% current = current_menu_item?(item) %> <% classes = "flex items-center h-full px-2.5 no-underline text-(--aat-header-text) hover:bg-(--aat-menu-pill) hover:text-(--aat-menu-hover-text) #{'bg-(--aat-menu-pill) text-(--aat-menu-hover-text) selected' if current}" %> -
  • +
  • > <% if children %> <% menu_id = "top-menu-#{item.id}" %> - <%= link_to url.presence || "#", item.html_options.merge(class: "#{classes} gap-1", data: { dropdown_toggle: menu_id, dropdown_trigger: "hover", dropdown_placement: "bottom-start", dropdown_offset_distance: 0, dropdown_delay: 100 }) do %> + <%= link_to url.presence || "#", item.html_options.merge(class: "#{classes} gap-1", "aria-haspopup": "true", "aria-controls": menu_id) do %> <%= item.label(self) %> <% end %> - <% end %> +<%= render "active_admin/page_banner" unless local_assigns[:page_banner] == false %> diff --git a/app/views/active_admin/_page_banner.html.erb b/app/views/active_admin/_page_banner.html.erb new file mode 100644 index 0000000..ce3016e --- /dev/null +++ b/app/views/active_admin/_page_banner.html.erb @@ -0,0 +1 @@ +<%# Empty on purpose: rendered below the flash messages on logged-in pages. An app overrides app/views/active_admin/_page_banner.html.erb to show a banner, such as the environment name. %> diff --git a/app/views/layouts/active_admin_logged_out.html.erb b/app/views/layouts/active_admin_logged_out.html.erb index 706e39c..5625e19 100644 --- a/app/views/layouts/active_admin_logged_out.html.erb +++ b/app/views/layouts/active_admin_logged_out.html.erb @@ -6,7 +6,7 @@
    - <%= render "active_admin/flash_messages" %> + <%= render "active_admin/flash_messages", page_banner: false %> <%= yield %>
    diff --git a/test/dummy/app/views/active_admin/_page_banner.html.erb b/test/dummy/app/views/active_admin/_page_banner.html.erb new file mode 100644 index 0000000..7b52ae5 --- /dev/null +++ b/test/dummy/app/views/active_admin/_page_banner.html.erb @@ -0,0 +1,4 @@ +<%# test/layout_test.rb: the host override of the theme's empty banner partial. %> +<% if params[:banner] %> +
    Staging environment
    +<% end %> diff --git a/test/layout_test.rb b/test/layout_test.rb index e4b29d9..69ffce2 100644 --- a/test/layout_test.rb +++ b/test/layout_test.rb @@ -40,6 +40,18 @@ def test_menu_group_opens_with_the_keyboard assert_selector "#top-menu-demo_pages a", text: "Wide table", visible: :visible end + def test_host_page_banner_shows_below_the_flashes_on_logged_in_pages + visit "/admin/customers" + assert_no_selector "#host-banner" + visit "/admin/customers?banner=1" + assert_selector "#host-banner", text: "Staging environment" + header = page.evaluate_script("document.getElementById('page-header').getBoundingClientRect().bottom") + banner = page.evaluate_script("document.getElementById('host-banner').getBoundingClientRect().top") + assert_operator banner, :>=, header + visit "/login_preview?banner=1" + assert_no_selector "#host-banner" + end + def test_desktop_has_top_menu_and_no_drawer visit "/admin/customers" assert_selector "#site-header nav a", text: "Customers" From 5daee9a66101e0ef6a636703b46f9fa815e23825 Mon Sep 17 00:00:00 2001 From: Denis Talakevich Date: Thu, 3 Dec 2026 16:23:41 +0200 Subject: [PATCH 15/15] Attributes table: a long pre scrolls inside its cell Capped at --aat-attributes-pre-max-height, 24rem by default, so a many-line value no longer stretches the row past the screen. Co-Authored-By: Clanker --- README.md | 2 ++ app/tailwind/active_admin_theme.css | 7 +++++++ test/dummy/app/admin/components_demo.rb | 6 ++++++ test/form_look_test.rb | 11 +++++++++++ 4 files changed, 26 insertions(+) diff --git a/README.md b/README.md index fd424ff..9a9c96d 100644 --- a/README.md +++ b/README.md @@ -329,6 +329,8 @@ text_node pre_wrap(response.body, max_height: "20rem") row(:payload) { |order| pre_wrap(order.payload, max_height: 240) } ``` +Any `pre` in an `attributes_table` cell, with or without `pre_wrap`, is capped at 24rem and scrolls the rest. To change the cap, set `--aat-attributes-pre-max-height` in your CSS. A `max_height:` of its own wins. + ### `secret_reveal` A masked value with an eye icon before it. A click fetches and shows the value, and the icon turns to an eye-off icon that hides it again. The URL must return `{"value": "..."}`. Needs the `active_admin_theme/secret_reveal` script. diff --git a/app/tailwind/active_admin_theme.css b/app/tailwind/active_admin_theme.css index e2b0c7a..504c39c 100644 --- a/app/tailwind/active_admin_theme.css +++ b/app/tailwind/active_admin_theme.css @@ -764,6 +764,13 @@ body { display: none; } +/* A long preformatted value in an attributes table scrolls inside its cell. A + * pre_wrap with its own max_height keeps it. */ +.attributes-table :where(tbody > tr > td) > pre:not(.aat-pre-wrap-capped) { + max-height: var(--aat-attributes-pre-max-height, 24rem); + overflow: auto; +} + /* ActiveAdmin's gray-400/50 and dark gray-600/50 are barely readable. These * grays keep about 3:1 on white and 4.6:1 on the dark panel, well under values, * so EMPTY stays readable and reads as a blank. */ diff --git a/test/dummy/app/admin/components_demo.rb b/test/dummy/app/admin/components_demo.rb index ffcdb4a..f643828 100644 --- a/test/dummy/app/admin/components_demo.rb +++ b/test/dummy/app/admin/components_demo.rb @@ -88,6 +88,12 @@ div id: "pre-wrap-capped-px" do text_node pre_wrap((1..40).map { |n| "line #{n}" }.join("\n"), max_height: 90) end + div id: "pre-long-row" do + attributes_table_for ActiveSupport::OrderedOptions.new.merge!(payload: (1..80).map { |n| "line #{n}" }.join("\n")) do + row(:payload) { |record| pre_wrap(record.payload) } + row(:capped) { |record| pre_wrap(record.payload, max_height: "6rem") } + end + end div id: "pre-wrap-blank" do attributes_table_for ActiveSupport::OrderedOptions.new.merge!(payload: " ") do row(:payload) { |record| pre_wrap(record.payload) } diff --git a/test/form_look_test.rb b/test/form_look_test.rb index 8a17a43..e9e421e 100644 --- a/test/form_look_test.rb +++ b/test/form_look_test.rb @@ -124,6 +124,17 @@ def test_theme_button_classes_work_outside_action_items_and_forms assert_equal "rgb(44, 49, 55)", style("#secondary-button", "backgroundColor") end + def test_a_long_pre_in_an_attributes_table_scrolls_inside_its_cell + visit "/admin/components" + long = "#pre-long-row tr:first-child pre" + assert_equal "384px", style(long, "maxHeight") + assert page.evaluate_script("(p => p.scrollHeight > p.clientHeight && p.clientHeight <= 384)(document.querySelector(#{long.to_json}))") + assert_equal "96px", style("#pre-long-row tr:last-child pre", "maxHeight") + + page.execute_script("document.documentElement.style.setProperty('--aat-attributes-pre-max-height', '10rem')") + assert_equal "160px", style(long, "maxHeight") + end + def test_a_panel_after_the_form_actions_has_a_gap visit "/admin/form_panels" gap = rect("#form-result")[2] - rect("#form-panels [type=submit]")[3]