Skip to content

Theme 4.0 for ActiveAdmin 4 - #78

Draft
senid231 wants to merge 32 commits into
activeadmin-plugins:masterfrom
senid231:activeadmin-v4
Draft

senid231 wants to merge 32 commits into
activeadmin-plugins:masterfrom
senid231:activeadmin-v4

Conversation

@senid231

@senid231 senid231 commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Theme 4.0 for ActiveAdmin 4. ActiveAdmin 4 replaced its Sass and jQuery front end with Tailwind CSS v4, Flowbite and import maps, so theme 3 can't be ported file by file. This PR rebuilds the theme on the new layout. Theme 3 moves to the 3.x maintenance branch.

Decisions to review

  • ActiveAdmin views copied. The theme overrides 10 ActiveAdmin 4.0.0.beta23 views (layout, header, navigation, page header, sidebar, show page, _html_head). Rails always renders the copy, so ActiveAdmin fixes to those files don't reach theme users. test/aa_overrides_test.rb records a digest of each original and fails when a new ActiveAdmin version changes one. Run it with UPDATE_AA_DIGESTS=1 after you merge the upstream change into the copy.
  • JavaScript. ActiveAdmin pages render only ActiveAdmin.importmap, so the engine pins the theme modules there. The theme's _html_head imports the modules listed in ActiveAdminTheme.javascripts. A pin in the host's own config/importmap.rb loads nothing on ActiveAdmin pages; the README says so.
  • CSS. The theme ships two delivery routes. The npm package exports ./css. The gem-path route uses rake active_admin_theme:css, which writes the machine-specific gem path into a git-ignored active_admin_theme.generated.css.
  • Requirements. Ruby 3.3 or later and ActiveAdmin 4.0.0.beta23 or later, the same as ActiveAdmin 4. The version is 4.0.0.pre.

Upstream proposals

These would shrink the copied views. None has been merged or reviewed yet.

activeadmin/activeadmin#9146 makes the layout extensible without copying views. With all five pull requests below, the theme drops its copies of the layout, _site_header, _main_navigation, _html_head and _page_header, and overrides small partials instead. I tested this against a branch that merges all five.

activeadmin/activeadmin#9147 supports running ActiveAdmin from a Rails engine and adding JavaScript to its pages:

Checklist

Packaging:

  • Gemspec, Gemfile, npm package.json (exports ./css and ./*), version 4.0.0.pre
  • CI: Ruby 3.3 and 3.4 with Node 22, bundle exec rake test
  • Dummy app rebuilt on ActiveAdmin 4 (Propshaft, importmap, Tailwind CLI), with customers, orders, countries and cities
  • Push 3.x to this repository; it is only on a fork today

Layout:

  • Top menu from 768px with dropdown submenus; drawer menu below 768px
  • Compact header with server clock, dark mode switch, user and logout icon
  • Compact breadcrumbs, title and action items; action items styled as buttons
  • Sidebar on the left, collapsible, and above the content on mobile
  • Index tables scroll sideways; cells stay on one line
  • Theme 3 colors, density and dark mode as --aat-* CSS custom properties
  • Side-by-side comparison with theme 3 screenshots
  • Logged-out layout checked on a real login page (the dummy has no Devise)

DSL and components:

  • columns / column, tabs / tab, panels around sidebar sections and the show page
  • confirm_dialog on the Flowbite modal, with form fields
  • status_tag color variants and a color: option
  • Searchable select on Tom Select (vendored 2.6.2): form and filter inputs, JSON source DSL, paging, dependent selects
  • truncate_text, secret_reveal, with_tooltip, pre_wrap
  • Server clock and table crisscross as ES modules without jQuery

Docs and release:

  • README rewritten for theme 4
  • docs/migrating-from-v3.md
  • Switch to the ActiveAdmin hooks once they are released
  • Release 4.0.0

Verification

bundle exec rake test passes locally: 68 runs, including headless Chrome tests for the layout, components, confirm dialog and searchable select. I checked index, show and form pages at 1280px, 820px and 390px, in light and dark mode, with test/screenshot.rb.

Rebuilds the theme on ActiveAdmin 4's Tailwind layout. Theme 3 stays on
the 3.x branch. The theme copies ten ActiveAdmin views, so
test/aa_overrides_test.rb fails when ActiveAdmin changes one of them.

Co-Authored-By: Clanker
The theme's markup now lives in the partials that ActiveAdmin's pending
layout hooks render. When the installed ActiveAdmin lacks them, the engine
adds app/views_compat, whose copies of the layout and headers render the
same partials. The JavaScript list and the import map cache watch use the
new ActiveAdmin settings when present. The searchable_select_options DSL
is included before host initializers, so a host's own version wins.

Co-Authored-By: Clanker
ActiveAdmin 4 dropped parent chains and raises TypeError for
`menu parent: [...]`, which apps upgrading from ActiveAdmin 3 still use.
The theme restores the chain and renders any depth in the top menu
and the drawer.

Co-Authored-By: Clanker
The top menu and a plain with_tooltip had only Tailwind classes or a
title to select them by. The page objects need a stable attribute.

Co-Authored-By: Clanker
Loaded with require "active_admin_theme/page_objects", never by the
theme itself. The base sections break on the theme's two menus and on
tabs, so those are patched. The searchable select and the components
get sections of their own.

Co-Authored-By: Clanker
Co-Authored-By: Clanker
The class Flowbite toggles is a Tailwind utility; the attribute is not.

Co-Authored-By: Clanker
Rails already loads an engine's lib/tasks, so the rake_tasks block ran
the task body a second time on every call.

Co-Authored-By: Clanker
A host that defined it before the theme's initializer ran, from a gem or
another engine, lost to the theme's later include.

Co-Authored-By: Clanker
confirm_dialog takes trigger: false, trigger_html: and params:, and
confirm_dialog_tag renders it from ERB and action_item blocks.
truncate_text takes popup: true.

Co-Authored-By: Clanker
active_admin_page_objects now has a public registry of field and filter
classes, so the theme no longer overrides its private detection.

Co-Authored-By: Clanker
The select script joins the default scripts and upgrades filter and form
selects on its own; tom_select: sets or skips it per select. The
searchable select gains a 3 character minimum, load-all, per_page and a
value other than the id. The endpoint now answers with pagination.more
instead of has_more, sorts newest first and pages by 50.

Co-Authored-By: Clanker
Only a Symbol name is titlecased now, so "Estimated spend" no longer
renders as "Estimated Spend".

Co-Authored-By: Clanker
Inside the action items it took the white .action-item-button look
while its neighbours were primary buttons. confirm_dialog also takes
class: for the trigger.

Co-Authored-By: Clanker
Four action items squeezed the page title and wrapped the breadcrumbs
at 390px.

Co-Authored-By: Clanker
Typing a query again while its next page was still due showed that page
in place of the first. The select also marks itself as searching from
the keystroke, which the page objects wait on before they click.

Co-Authored-By: Clanker

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The selected-option lookup bypasses source and authorization scopes, allowing crafted filter values to expose restricted record labels.

6 open issues
1 file not reviewed
  • test/dummy/package-lock.json: Generated file
What changed in this PR

Rebuilds the theme for ActiveAdmin 4’s Tailwind CSS, Flowbite, and import-map frontend, replacing the previous Sass and jQuery integration.

Changes:

  • Introduces compact layouts, responsive navigation, reusable components, and searchable selects.
  • Adds engine integration, CSS delivery options, page objects, and migration documentation.
  • Rebuilds the dummy app and expands automated coverage for the new frontend.
File Description
test/​trix_screenshot.rb Removes legacy Trix screenshots.
test/​smoke_test.rb Checks page rendering and theme configuration.
test/​searchable_select_test.rb Tests searchable-select browser behavior.
test/​searchable_select_options_test.rb Tests options endpoints and configuration.
test/​searchable_select_off_test.rb Tests opt-in-only select enhancement.
test/​screenshot.rb Captures multiple widths and color modes.
test/​rake_tasks_test.rb Checks CSS task registration.
test/​page_objects_select_control_test.rb Tests native and enhanced select controls.
test/​page_objects_searchable_select_test.rb Tests searchable-select page objects.
test/​page_objects_helper.rb Defines shared browser setup and pages.
test/​page_objects_components_test.rb Tests component page objects.
test/​host_dsl_test.rb Checks host DSL precedence.
test/​fixtures/​active_admin_originals.yml Records upstream view digests.
test/​dummy/​tailwind-active_admin.config.js Configures Tailwind source scanning.
test/​dummy/​package.json Adds frontend dependencies and build scripts.
test/​dummy/​config/​initializers/​active_admin.rb Configures demo authentication and modules.
test/​dummy/​config/​importmap.rb Documents the separate ActiveAdmin import map.
test/​dummy/​config/​environment.rb Creates and seeds demo tables.
test/​dummy/​config/​database.yml Switches to file-backed SQLite.
test/​dummy/​config/​application.rb Adopts Propshaft and import maps.
test/​dummy/​app/​tailwind/​active_admin.css Imports Tailwind and theme styles.
test/​dummy/​app/​models/​street.rb Adds dependent-select demo records.
test/​dummy/​app/​models/​shipment.rb Supports advanced select demos.
test/​dummy/​app/​models/​product.rb Adds searchable product data.
test/​dummy/​app/​models/​parcel.rb Supports nested-form demos.
test/​dummy/​app/​models/​order.rb Supports order forms and filters.
test/​dummy/​app/​models/​customer.rb Adds customer demo records.
test/​dummy/​app/​models/​country.rb Supports country selectors.
test/​dummy/​app/​models/​city.rb Supports dependent city selectors.
test/​dummy/​app/​controllers/​application_controller.rb Supplies a demo signed-in user.
test/​dummy/​app/​assets/​stylesheets/​active_admin.scss Removes the legacy Sass entry point.
test/​dummy/​app/​assets/​javascripts/​active_admin.js Removes the Sprockets script entry point.
test/​dummy/​app/​assets/​config/​manifest.js Removes the Sprockets manifest.
test/​dummy/​app/​assets/​builds/​.keep Preserves the CSS output directory.
test/​dummy/​app/​admin/​wide_table.rb Updates navigation and action-item demos.
test/​dummy/​app/​admin/​table.rb Groups the table demo in navigation.
test/​dummy/​app/​admin/​shipments.rb Demonstrates advanced and dynamic selects.
test/​dummy/​app/​admin/​searchable_select_demo.rb Demonstrates searchable forms and filters.
test/​dummy/​app/​admin/​nested_menu_demo.rb Demonstrates deeper menu nesting.
test/​dummy/​app/​admin/​layout_demo.rb Demonstrates column layouts.
test/​dummy/​app/​admin/​editor.rb Removes the legacy Trix demo.
test/​dummy/​app/​admin/​customers.rb Demonstrates themed resource pages.
test/​dummy/​app/​admin/​confirm_dialog_demo.rb Demonstrates dialog forms and submissions.
test/​dummy/​app/​admin/​components_demo.rb Demonstrates reusable UI components.
test/​css_import_test.rb Tests generated CSS imports.
test/​crisscross_screenshot.rb Removes legacy highlighting screenshots.
test/​confirm_dialog_test.rb Tests dialog interaction and validation.
test/​components_test.rb Tests component rendering and behavior.
test/​clock_test.rb Removes legacy clock and sticky-header tests.
test/​capybara_boot.rb Updates shared browser configuration.
test/​aa_overrides_test.rb Checks copied views against upstream digests.
Rakefile Builds CSS before running test files.
package.json Publishes theme CSS and ES modules.
lib/​tasks/​active_admin_theme.rake Adds the host CSS-generation task.
lib/​active_admin_theme/​views/​with_tooltip.rb Loads the tooltip helper.
lib/​active_admin_theme/​views/​truncate_text.rb Adds truncation and popup rendering.
lib/​active_admin_theme/​views/​tabs.rb Restores tabs using Flowbite.
lib/​active_admin_theme/​views/​status_tag.rb Adds configurable status colors.
lib/​active_admin_theme/​views/​secret_reveal.rb Renders secret-reveal controls.
lib/​active_admin_theme/​views/​searchable_select.rb Loads the searchable-select DSL.
lib/​active_admin_theme/​views/​pre_wrap.rb Loads the preformatted-text helper.
lib/​active_admin_theme/​views/​confirm_dialog.rb Renders modal forms and fields.
lib/​active_admin_theme/​views/​columns.rb Restores weighted column layouts.
lib/​active_admin_theme/​version.rb Sets the theme 4 prerelease version.
lib/​active_admin_theme/​sidebar_title.rb Preserves sidebar title conventions.
lib/​active_admin_theme/​resource_dsl/​searchable_select.rb Adds paginated options endpoints.
lib/​active_admin_theme/​page_objects/​truncate_text.rb Exposes truncated text and popups.
lib/​active_admin_theme/​page_objects/​tooltip.rb Exposes tooltip content and visibility.
lib/​active_admin_theme/​page_objects/​tabs.rb Adds tab navigation helpers.
lib/​active_admin_theme/​page_objects/​status_tag.rb Exposes status values and colors.
lib/​active_admin_theme/​page_objects/​sidebar.rb Adds sidebar panel lookups.
lib/​active_admin_theme/​page_objects/​selectors.rb Registers theme-specific selectors.
lib/​active_admin_theme/​page_objects/​secret_reveal.rb Drives reveal controls and errors.
lib/​active_admin_theme/​page_objects/​pre_wrap.rb Reads preserved text formatting.
lib/​active_admin_theme/​page_objects/​main_menu.rb Supports desktop and drawer navigation.
lib/​active_admin_theme/​page_objects/​layout.rb Adds themed layout sections and controls.
lib/​active_admin_theme/​page_objects/​confirm_dialog.rb Drives dialog forms and actions.
lib/​active_admin_theme/​page_objects/​component.rb Provides component lookup helpers.
lib/​active_admin_theme/​page_objects/​columns.rb Exposes columns and weights.
lib/​active_admin_theme/​page_objects.rb Adds the optional page-object entry point.
lib/​active_admin_theme/​nested_menu.rb Restores nested menu chains.
lib/​active_admin_theme/​inputs/​searchable_select_input.rb Adds searchable inputs and select settings.
lib/​active_admin_theme/​helpers/​tooltip.rb Renders plain and HTML tooltips.
lib/​active_admin_theme/​helpers/​pre_wrap.rb Renders wrapping preformatted text.
lib/​active_admin_theme/​helpers/​confirm_dialog.rb Adds dialog rendering and trigger helpers.
lib/​active_admin_theme/​helpers/​config.rb Exports localized frontend configuration.
lib/​active_admin_theme/​engine.rb Registers views, modules, and extensions.
lib/​active_admin_theme/​css_import.rb Generates machine-specific stylesheet imports.
lib/​active_admin_theme.rb Defines theme loading and configuration.
Gemfile Updates development and test dependencies.
docs/​migrating-from-v3.md Explains migration and removed features.
config/​importmap.rb Pins theme modules and Tom Select.
app/​views/​layouts/​active_admin_logged_out.html.erb Adds the themed logged-out layout.
app/​views/​active_admin/​shared/​_sidebar_section.html.arb Wraps sidebar sections in panels.
app/​views/​active_admin/​resource/​show.html.arb Adds panels around show-page attributes.
app/​views/​active_admin/​resource/​_show_default.html.arb Themes default resource details.
app/​views/​active_admin/​_sidebar.html.erb Adds collapsible sidebar markup.
app/​views/​active_admin/​_page_title.html.erb Renders compact page titles.
app/​views/​active_admin/​_page_heading.html.erb Combines breadcrumbs, title, and sidebar toggle.
app/​views/​active_admin/​_page_content.html.erb Defines the sidebar/content grid.
app/​views/​active_admin/​_main_navigation.html.erb Renders the mobile drawer.
app/​views/​active_admin/​_header_navigation.html.erb Renders desktop dropdown navigation.
app/​views/​active_admin/​_header_leading.html.erb Renders site title and drawer control.
app/​views/​active_admin/​_header_actions.html.erb Renders clock, user, and header controls.
app/​views/​active_admin/​_breadcrumbs.html.erb Renders compact breadcrumbs.
app/​views/​active_admin_theme/​_menu_flyout.html.erb Renders nested desktop submenus.
app/​views/​active_admin_theme/​_menu_drawer.html.erb Renders nested drawer items.
app/​views_compat/​layouts/​active_admin.html.erb Supplies the pre-hook layout fallback.
app/​views_compat/​active_admin/​_site_header.html.erb Supplies the compact header fallback.
app/​views_compat/​active_admin/​_page_header.html.erb Supplies the page-header fallback.
app/​views_compat/​active_admin/​_html_head.html.erb Loads assets and configured modules.
app/​tailwind/​components/​truncate_text.css Styles truncation and popups.
app/​tailwind/​components/​status_tag.css Defines status color treatments.
app/​tailwind/​components/​secret_reveal.css Styles reveal controls and errors.
app/​tailwind/​components/​pre_wrap.css Preserves whitespace with wrapping.
app/​tailwind/​components/​confirm_dialog.css Styles responsive modal forms.
app/​javascript/​active_admin_theme/​table_crisscross.js Reimplements table highlighting without jQuery.
app/​javascript/​active_admin_theme/​server_clock.js Adds the ES-module server clock.
app/​javascript/​active_admin_theme/​secret_reveal.js Fetches and displays secret values.
app/​javascript/​active_admin_theme/​layout.js Handles sidebar state and flyout placement.
app/​javascript/​active_admin_theme/​confirm_dialog.js Adds dialog focus and validation behavior.
app/​assets/​javascripts/​wigu/​theme_toggle.js Removes the legacy theme switcher.
app/​assets/​javascripts/​wigu/​table_crisscross.js Removes jQuery-based highlighting.
app/​assets/​javascripts/​wigu/​server_clock.js Removes the legacy clock implementation.
app/​assets/​javascripts/​wigu/​scrollbar_width.js Removes obsolete scrollbar compensation.
app/​assets/​javascripts/​wigu/​all.js Removes the Sprockets umbrella entry point.
active_admin_theme.gemspec Updates metadata and compatibility requirements.
.gitignore Adjusts generated-file exclusions.
.github/​workflows/​ci.yml Runs tests with Ruby 3.3/3.4 and Node 22.

Review effort: Balanced

Comment thread lib/active_admin_theme/views/tabs.rb Resolved
Comment thread test/aa_overrides_test.rb Resolved
The block kept the view as self, so Arbre tags such as para raised
NoMethodError inside an action item.

Co-Authored-By: Clanker
The input showed the label of any record id put in the URL or form. It now
applies the endpoint resource's read scope and a param-free scope:, labels a
value outside it with the value itself so a save keeps it, and raises for a
lambda value:, which cannot be looked up.

Co-Authored-By: Clanker
Flowbite passes each tab's target to querySelector, so a numeric title
such as 2024 threw and left every tab on the page dead.

Co-Authored-By: Clanker

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Unresolved tab ID collisions, missing nested-resource route parameters, tooltip and popup accessibility defects, and popup-dependent truncation detection leave functional and accessibility issues.

No open issues 🎉

5 previously missed issues

In code that hasn't changed since last review

Medium severity Popup cannot be dismissed with Escape

app/​tailwind/​components/​truncate_text.css:49

The popup remains visible for as long as its trigger is hovered or focused, and there is no Escape handler to dismiss it. Since it can cover surrounding content, users must move the pointer or keyboard focus just to uncover that content; this fails the dismissibility requirement for content shown on hover/focus (WCAG 1.4.13). Please add Escape dismissal that keeps focus on the trigger and suppresses the popup until the next hover/focus interaction.

Medium severity Tooltip trigger is not keyboard-accessible or associated with its description

lib/​active_admin_theme/​helpers/​tooltip.rb:15

For the documented text-content usage, this span is not keyboard-focusable and has no accessible description linking it to the tooltip. Keyboard users therefore cannot reveal the HTML tooltip, and assistive technology cannot associate its explanation with the displayed value. Make the trigger focusable and reference the tooltip with aria-describedby.

Medium severity Popup text makes cut? report truncation when none occurred

lib/​active_admin_theme/​page_objects/​truncate_text.rb:44

Once a popup: true value is hovered or focused, the component's visible text includes both .aat-truncate-text and the popup's full text. Consequently cut? returns true even when no length: truncation occurred, and its result changes just by opening the popup. Compare the inner displayed-text span with full_text for popup components instead of reading the entire root.

Medium severity Searchable select omits required parent route parameters

lib/​active_admin_theme/​resource_dsl/​searchable_select.rb:30

For a target resource registered with a required belongs_to, this calls route_collection_path without the parent ID, so rendering the searchable select raises ActionController::UrlGenerationError even when the current request has that ID. ActiveAdmin's route contract accepts parent parameters. Please pass the relevant route parameters from the input's view/controller through searchable_select_path to the route builder.

Medium severity Generated panel IDs can collide with tab button IDs

lib/​active_admin_theme/​views/​tabs.rb:29

With tabs titled Summary and Summary tab, the second panel receives id="summary-tab", which is already the first tab button's ID. Only panel/base IDs are registered, not the derived button IDs, so Flowbite's #summary-tab target can resolve to the button instead of the second panel. Reserve all emitted IDs (including button and container IDs) when choosing generated IDs, and cover this pair of distinct titles in the regression test.

6 resolved since last review
1 file not reviewed
  • test/dummy/package-lock.json: Generated file

Review effort: Balanced

@senid231 senid231 self-assigned this Nov 25, 2026
Page objects: ConfirmDialog fills and returns body controls by label, id
or name and can confirm without browser validation; TruncateText#clipped?
reads the CSS ellipsis. Only index tables keep cells on one line, and the
README explains the importmap sweeper order for hosts that watch a
directory of their own.

Co-Authored-By: Clanker
Hosts moving from theme 3.x asked for the old density and layout. The
attributes table becomes a grid in CSS only, so ActiveAdmin's row markup
stays and page objects keep working; ARIA roles restore the table
semantics the grid drops.

Co-Authored-By: Clanker
Chrome reports the CSS-uppercased text, so specs comparing "verified" failed. has_text? now ignores case for a String.

Co-Authored-By: Clanker
Reviewers found the tab content and attributes tables hard to tell from the page. This restores v3's surface boxes, cell padding and a faint label tint.

Co-Authored-By: Clanker
The user compared the show page with a v3 screenshot: v3 has no inner box or label tint on attributes tables in a panel, boxed inactive tabs, and roomier padding.

Co-Authored-By: Clanker
ActiveAdmin's base blue and an unlayered header link rule hid the v3 link colours and menu hover text. Status tags go back to v3's solid fills, as the user asked.

Co-Authored-By: Clanker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants