Skip to content

Theme 4.0 for ActiveAdmin 4 - #78

Merged
senid231 merged 81 commits into
activeadmin-plugins:masterfrom
senid231:activeadmin-v4
Dec 2, 2026
Merged

senid231 merged 81 commits into
activeadmin-plugins:masterfrom
senid231:activeadmin-v4

Conversation

@senid231

@senid231 senid231 commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Theme 4 for ActiveAdmin 4.0.0.beta23 and later, on Ruby 3.3 or later. ActiveAdmin 4 replaced Sass, Sprockets and jQuery with Tailwind CSS 4, ERB partials and import maps, so theme 3 couldn't be ported file by file. This PR rebuilds the theme and keeps the theme 3 look. Theme 3 continues on the 3.x branch. After the merge, v4.0.0.beta1 is tagged as a GitHub pre-release; nothing goes to RubyGems.

Decisions a reviewer can't see in the diff

  • Copied ActiveAdmin views. The theme overrides 10 ActiveAdmin views, so upstream fixes to them don't reach theme users. test/aa_overrides_test.rb fails when a new ActiveAdmin version changes one of the originals.
  • JavaScript. ActiveAdmin pages load only ActiveAdmin.importmap, so the engine pins its modules there. A pin in the app's own config/importmap.rb doesn't load on admin pages.
  • CSS. Two routes: the npm package's ./css export, or rake active_admin_theme:css, which writes a git-ignored file with the gem path.
  • Searchable select. Vendored Tom Select 2.6.2 replaces select2, with the same DSL and JSON endpoints.
  • Page objects. active_admin_theme/page_objects extends active_admin_page_objects 2.0.0.beta1 for the theme's widgets.

What users notice

  • The header holds the server clock, the current user, a logout icon, and an auto, light and dark switch.
  • Colors are --aat-* CSS custom properties instead of $skin* Sass variables.
  • Trix theming, sticky table headers and the sizing variables are not ported.

Upgrade steps are in docs/migrating-from-v3.md.

Upstream proposals

activeadmin/activeadmin#9146 and activeadmin/activeadmin#9147 would let the theme drop most copied views. None is merged yet; the suite also passes on a branch with all of them.

Verification

CI runs bundle exec rake test on Ruby 3.3, 3.4 and 4.0: 396 tests, most in headless Chrome. A production app on theme 3 was migrated, and its screens were compared with theme 3; the only differences left are ones the maintainer approved.

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
RubyGems treats 5.0.0.beta1 as below 5.0, so the old bound let ActiveAdmin 5
prereleases in.

Co-Authored-By: Clanker
The helper is renamed from status_tag_tag to status_tag, and aat_arbre to
arbre. One class method on the StatusTag component computes the content and
attributes for both the Arbre component and the helper, so they render the
same markup. Per cell, the helper allocates 44 objects instead of 106 and is
1.5 to 2.5 times faster than building an Arbre context.

Co-Authored-By: Clanker
`options` now reads the native select, as the base SelectField does, and
`dropdown_options` lists what the open dropdown offers. `type` picks the
highlighted option with Enter through the driver keyboard, because Cuprite
0.17 clicks before send_keys and that click closes a multiple select.

Co-Authored-By: Clanker
Specs that fill through `form.fill(field: value)` cannot pass `exact:`, so
ActiveAdminTheme::PageObjects.searchable_select_exact sets the default of
fill, choose and select_option. It stays true.

Co-Authored-By: Clanker
Gem commits before 8ec1677d also report 2.0.0.alpha, so the version check
let them through and the theme failed with a NameError on StatusTag.

Co-Authored-By: Clanker
2.0.0.beta1 is the first 2.x version that tells itself apart from the older
2.0.0.alpha commits without StatusTag, so the version check replaces the
constant guard.

Co-Authored-By: Clanker
Co-Authored-By: Clanker
In a plain select with hundreds of options, search returned before Tom
Select filtered the list, so the next lookup read every option, and the
first keystrokes could be lost. Typing now retries once when the input
lost the text, then waits until Tom Select's lastQuery matches the input.

Co-Authored-By: Clanker
The CI runner's time zone list is shorter than a local one, so fillers make
the long select 600 options everywhere. The lazy load test counted loaded
events from every placeholder and failed when another one loaded at the
same time.

Co-Authored-By: Clanker
A page that wraps tabs and a collapsible panel in a form painted their
buttons as submit buttons, and a panel right after the form actions touched
the button. Filter and Clear Filters now share the sidebar width, and the
related records list drops the rules between links.

Co-Authored-By: Clanker
ActiveAdmin's switch only flips light and dark, so after one click a page no
longer followed the OS. The theme's switch cycles the three modes on
ActiveAdmin's own "theme" key, as theme 3.x did. EMPTY values in dark mode
use v3's #bbb instead of ActiveAdmin's faint gray.

Co-Authored-By: Clanker
The parentheses come from CSS, so the count element's text stays the bare
number that the page objects parse.

Co-Authored-By: Clanker
@senid231
senid231 marked this pull request as ready for review December 1, 2026 18:03
Tom Select dropped the class and the data attribute of each native option,
so apps could not style the None and Present choices. The option and the item
now keep both, the choices are italic and muted by default, and a dependent
select passes the Present marker on as `_not_null`.

Co-Authored-By: Clanker
Parentheses drawn by CSS are not page text, so a spec that matched
"All (6)" would see "All 6". The count is now a bold, muted number set
apart from the name, and its text stays the number page objects read.

Co-Authored-By: Clanker
The README had no picture of theme 4, and img/ held only theme 3 shots that
nothing referenced. `rake screenshots` regenerates the new set from the
dummy app, whose customer statuses now get colors as an app's would. The
phone-width Filter button no longer takes the 16px input size.

Co-Authored-By: Clanker
A remote select scored only the ids of the last reply, and each new query
cleared the options, so the None and Present choices of filter_extensions
vanished once the user typed. They now stay listed above the endpoint's
results and match the typed text. The page objects' search replaces the
text in the box, and options leaves out the blank choice as documented.

Co-Authored-By: Clanker
Tom Select's remove_button plugin puts the × right after the chosen
label; select2 in theme v3 had it at the right edge, left of the arrow.

Co-Authored-By: Clanker
The README installed the RubyGems gem, which is theme 3, and the
migration guide still said the theme dropped its dark mode switch.

Co-Authored-By: Clanker
@senid231
senid231 merged commit 998d982 into activeadmin-plugins:master Dec 2, 2026
3 checks passed
@senid231
senid231 deleted the activeadmin-v4 branch December 2, 2026 10:48
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.

3 participants