Skip to content

fix(admin): keep form fields dark after a Turbo visit - #533

Merged
artempartos merged 1 commit into
developfrom
fix/admin-dark-fields-after-turbo
Oct 21, 2026
Merged

artempartos merged 1 commit into
developfrom
fix/admin-dark-fields-after-turbo

Conversation

@artempartos

Copy link
Copy Markdown
Contributor

Problem

In the admin's dark theme, form fields (reported on Companies → New) render with a white background and the skin's light grey text, so typed values look like placeholders. A full page load looks right; it breaks from the first click onward.

Cause

Administrate 1.0 bundles the CSS anchor positioning polyfill (vendor/css-anchor-positioning.js) in its auto-apply form. On every load, in every browser, it replaces the <link> to administrate/application-*.css with a blob: copy. On the next Turbo visit the incoming head carries the original link, Turbo treats it as a new stylesheet and appends it after admin.css. From then on every skin rule whose specificity equals Administrate's loses by source order — :root :where(input…) against [type=text] { background-color: #fff } — while the text color stays the skin's, because Administrate sets none.

Head order after one Turbo visit, before the fix:

blob:…(Administrate) > jsonb.css > fonts > admin.css > application-04100076.css

Fix

  • window.ANCHOR_POSITIONING_POLYFILL_OPTIONS = { elements: [] } before Administrate's script: the polyfill leaves stylesheets alone, so the head stays in the order the layout writes it. The only element it positions is the search hint popover. It now relies on native anchor positioning, which current Chrome, Safari and Firefox have. I checked it in Chromium: the popover opens anchored under its button.
  • The "No limit — unbilled" badge on the companies index and the permanent-delete section on a user's page carried the light palette inline. They use the skin's tokens now. In dark mode the badge's contrast goes from 2.37 to 7.54.
  • AdminSkinTokensTest also reads the admin views, so a view that uses an undeclared --app-* token fails it.

Verification

  • Local stack, browser driven through Turbo across 62 admin pages (index, show, edit and new for every resource, plus the dashboard, catalog syncs, invite members, move project and session admission), in both schemes. The check looked for light backgrounds in dark mode, text contrast below 4.5:1, and the skin not being the last stylesheet. With the fix the only finding left is the dev-only Bullet footer.
  • test/integration/admin/layout_test.rb pins the opt-out ahead of Administrate's script. It fails without the fix.
  • Ran locally: the changed tests, test/lib/changelog_test.rb, rubocop on the changed files, brakeman. The full suite runs on CI here.

🤖 Generated with Claude Code

Administrate 1.0 bundles the CSS anchor positioning polyfill in its
auto-apply form: in every browser it swaps the <link> to Administrate's
stylesheet for a blob: copy on load. On the next Turbo visit the head no
longer matches, so Turbo appends the original stylesheet after the skin,
and rules of equal specificity flip back to Administrate's - text fields
get its white background under the skin's light grey text. A full page
load never shows it, so the theme looked right until the first click.

Telling the polyfill to leave stylesheets alone keeps the head order
stable. The one element it positions, the search hint popover, uses the
browser's native anchor positioning instead.

The unbilled badge and the permanent-delete section carried the light
palette inline; they use the skin's tokens now, and the token test reads
the admin views too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
@artempartos
artempartos merged commit 2ecb0ec into develop Oct 21, 2026
16 checks passed
artempartos added a commit to Hitin/flow that referenced this pull request Oct 21, 2026
* commit '2ecb0ecb':
  fix(admin): keep form fields dark after a Turbo visit (AixleHQ#533)
  feat(overview): rename Total Spend card to Token Cost (AixleHQ#532)
  fix(admin): preload company session limits on the companies index (AixleHQ#523)
  fix(board): keep the board settings gear on the toolbar row (AixleHQ#524)
  feat(capacity): give every AWS Marketplace company at least 3 workers (AixleHQ#531)
  fix(mcp): refuse token changes while impersonating; error on a token no company accepts (AixleHQ#528)
  feat(feature-flags): registry, resolver and Feature facade (1/7) (AixleHQ#526)
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.

1 participant