Skip to content

CSS - Consolidate 3 sticky classes - #38215

Open
colemanw wants to merge 3 commits into
civicrm:masterfrom
colemanw:stickySituation
Open

colemanw wants to merge 3 commits into
civicrm:masterfrom
colemanw:stickySituation

Conversation

@colemanw

Copy link
Copy Markdown
Member

Overview

Gets us out of a sticky situation by consolidating 3 duplicate css rules.

See discussion at #38207

Technical Details

Over the years CiviCRM had accumulated 3 ways of making a sticky table header:

  • .sticky The OG D6 javascript version.
    • Used in 35 core templates and 35 extensions in universe, BUT...
    • It had no crm- prefix (which is our standard)
    • Most importantly, it was broken. I couldn't get it to work anywhere, and @bgm said the same thing back in 2024.
  • .crm-sticky-header The one I added to SearchKit (2023). Now used in hundreds of SearchDisplays.
    • Has a good implementation, just needed to be moved out of a searchkit-only css file
    • Since it's now in thousands of managed and user-saved searchDisplays, it would be very difficult to rename at this point.
  • .crm-sticky @shaneonabike added this in 2024
    • I foolishly merged it instead of suggesting we just move .crm-sticky-header out of searchkit's css and into core.
    • But it's still only used once in all of universe (the WP permission screen that Shane was working on)
    • The only other reference to it is in Dresscode

Given all that, the path seems pretty clear to me. This PR:

  1. Moves .crm-sticky-header css from searchKit to core/Riverlea
  2. Updates the one use of .crm-sticky and delete its css
  3. I was going to suggest a deprecation offramp for .sticky but given that it's been broken for years and no one's noticed, I'm updating all those tables to use .crm-sticky-header and deleting the defunct css.

Note: #38207 should have been closed instead of merged. It fixes the old .sticky rule by switching it to css instead of D7 javascript... but again, it's been broken for years. Replacing it IMO is better than fixing it. It's been non-functional for extensions in universe using that class, so ripping it out leaves it equally non-functional, but with an easy path forward for those extensions to adopt the new class.

Removes `.sticky` (broken, used D7 js) and `crm-sticky` (only used once) in favor of the `crm-sticky-header` class, moving it out of SearchKit and into core+riverlea.
@civibot

civibot Bot commented Nov 23, 2026

Copy link
Copy Markdown

🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷

Introduction for new contributors...
  • If this is your first PR, an admin will greenlight automated testing with the command ok to test or add to whitelist.
  • A series of tests will automatically run. You can see the results at the bottom of this page (if there are any problems, it will include a link to see what went wrong).
  • A demo site will be built where anyone can try out a version of CiviCRM that includes your changes.
  • If this process needs to be repeated, an admin will issue the command test this please to rerun tests and build a new demo site.
  • Before this PR can be merged, it needs to be reviewed. Please keep in mind that reviewers are volunteers, and their response time can vary from a few hours to a few weeks depending on their availability and their knowledge of this particular part of CiviCRM.
  • A great way to speed up this process is to "trade reviews" with someone - find an open PR that you feel able to review, and leave a comment like "I'm reviewing this now, could you please review mine?" (include a link to yours). You don't have to wait for a response to get started (and you don't have to stop at one!) the more you review, the faster this process goes for everyone 😄
  • To ensure that you are credited properly in the final release notes, please add yourself to contributor-key.yml
  • For more information about contributing, see CONTRIBUTING.md.
PR commands & links...
  • /rebase <?branch-name> will rebase your branch and change the base of the PR (if <branch-name> is specified).
  • /squash will combine all commits (keeping only the first commit messsage).
  • /port <branch-name> will create a copy of this PR against a different branch.
  • /lint will automatically fix linting errors, amending commits as needed.
  • retest this please will rerun the tests and rebuild the demo site.
  • 📖 Review standards
  • 🗒️ Review template (brief or verbose)

➡️ Online demo of this PR 🔗

@jfilter

jfilter commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

@civireview

@civireview civireview 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.

CiviReview: 🟢 Ready · Confidence: 5/5 ★★★★★

Summary: Consolidates three sticky-header CSS classes into .crm-sticky-header. It moves the rule out of SearchKit into core and Riverlea, and switches about 35 core and legacy-search templates from thead.sticky to a table-level class.

Merge Confidence (5/5): No verified issues; passed CI / Jenkins, Base-Test Regression, Live Surface Diff.

  • PR: civicrm/civicrm-core#38215 · Kind: ui-change · Commits: a6349c8 → c5c2a06

Findings

No verified high-signal issues found above the confidence gate.

Empirical Verification Matrix

Check Status Detail
CI / Jenkins ✅ PASS 1 CI checks: 1 passed, 0 failed, 0 pending.
Base-Test Regression ✅ PASS 145 test(s) passed on A and B
Live Surface Diff ✅ PASS Live APIv4/APIv3/routes/Afform surface diff captured with 0 risk flags.
Browser A/B (Standalone) ✅ PASS Probed 1 route(s), 1 screenshot pair(s); 0 new console/page/network/a11y/render regressions.

Not Verified:

  • No added/modified PHPUnit tests in PR; Proof-of-Fix A/B test skipped.
Standalone Browser A/B (1 route(s), 0 regressions)
  • Probed routes (1): civicrm/dashboard?reset=1
  • New console errors: 0 · Page errors: 0 · Network failures: 0 · A11y violations: 0 · Render regressions: 0
  • Screenshots: 1 before/after pair(s) captured
Detailed Walkthrough (7 notes)
  • CONFIRMED (diff): table.crm-sticky-header > thead > tr (sticky, top: var(--crm-menubar-bottom,0), z-index 2) is added to css/civicrm.css and Riverlea _tables.css. It is removed from search_kit and the Riverlea search_kit css. The .sticky, .crm-sticky and WP-toolbar rules are deleted.
  • CONFIRMED: about 35 templates move the class from <thead class="sticky"> to <table class="... crm-sticky-header">. The class is applied to the table, not the thead, matching the new selector.
  • CONFIRMED: The sticky rule now sits in core CSS, so it applies to every table with crm-sticky-header, and so does position: sticky !important.
  • PROVEN: Only the CI A/B PHPUnit run (145 tests) and a dashboard probe ran. Neither exercises any template touched by this PR. The probe showed no console errors or visual regressions on the one route it visited.
  • NEEDS_QUESTION: Several tables have multiple <thead> elements (DeferredRevenue, Report Layout Table) or no <tr> in thead (many <thead><th> templates). Sticky rows may behave oddly, or not apply, where thead has bare th elements without a tr.
  • NEEDS_QUESTION: The old sticky rule gave headers a background, border and shadow. The new rule sets none, so rows could turn transparent over scrolling content outside Riverlea. Sticky position may also fail inside overflow containers, and DataTables-wrapped tables may behave differently.
  • NOT VERIFIED: Visual behaviour under WordPress, Drupal, Joomla, Standalone and Riverlea, and the mobile menubar offset, whose WP-specific rules were removed. Extensions in universe that use .sticky lose their (already broken) styling.
CiviCRM Core Standards (4 checks — all PASS/N/A)
Code Status Note
r-explain PASS The PR body explains the three classes and why they are being consolidated.
r-tech PASS Removing .sticky and .crm-sticky changes a public CSS class contract, but the PR body states this and gives the reasoning: the old class was non-functional, and crm-sticky-header is the replacement. One small surviving UI finding (c1) affects the DeferredRevenue template only. It is not a technical-standards breach.
r-run PASS CI passed. The browser A/B run probed only the dashboard, so the sticky-header pages were not exercised and the overlap in c1 was not checked live.
r-user PASS Extensions can adopt crm-sticky-header as the replacement. One minor visual issue remains in the Deferred Revenue report (c1).

Ecosystem Blast Radius

Repo Path Symbol Impact
civicrm-core css/civicrm.css .crm-sticky-header / .sticky / .crm-sticky The old .sticky and .crm-sticky rules are removed. The .crm-sticky-header rule is now global rather than SearchKit-only.
civicrm-core ext/riverlea/core/css/components/_tables.css table.crm-sticky-header Riverlea now gets the sticky rule from this file, replacing the one in the SearchKit stylesheet fork.

Reviewed by civireview · sonnet-opus · 314,083 tokens · $0.57

@colemanw

Copy link
Copy Markdown
Member Author

@vingle that's a big review… don't think it will be this week

It's actually simpler than it looks. .crm-sticky-header was already the one standard actively-used, and this PR doesn't change it (just moves it to a different style file). The other 2 were either broken or barely-used. So if we already know .crm-sticky-header works, then this ought to be a safe change (or at least, not a source of regression as .crm-sticky-header will have the same number of existing bugs before as after).

@vingle

vingle commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

not a source of regression as .crm-sticky-header will have the same number of existing bugs before as after

But in many more parts of Civi? As the not-working .sticky is being swapped with the working .crm-sticky-header? Tho true, the main job is cross-CMS testing, not checking all the template outputs.

@colemanw

Copy link
Copy Markdown
Member Author

@vingle here's a quick screencap of this PR on Wordpress, including adjusting the window width to make the menubar wrap:

Screen.Recording.2026-11-25.at.1.22.26.PM.mov

Is that the testing you'd like to see on every CMS?

@vingle

vingle commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Is that the testing you'd like to see on every CMS?

@colemanw - good point! I'd not even been thinking of wrapping menu lines… there's also the issue of mobile view. I'd just been thinking menu above and menu below… ie

image & image

So to be really thorough we'd need both of these with wrapping menu lines…

And the mobile viewport, which on my quick tests is really broken (--crm-menubar-bottom: 583px; on Joomla, --crm-menubar-bottom: 1259.5px; on WordPress).

image

ie 5 scenarios on each cms (menu above single line & wrapping line, menu below single & wrapping, mobile).

@vingle

vingle commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

retest this please

@vingle

vingle commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

retest this for wordpress please

build wordpress
build drupal

(sorry can't remember the command)

@vingle

vingle commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

The mobile view on Standalone is broken - the table header has simply vanished…

image

I wonder if sonnet-opus might refund the $0.57 for it's "CiviReview: 🟢 Ready · Confidence: 5/5 ★★★★★" assessment.

@colemanw colemanw added run-wordpress Civibot should setup demos+tests for WordPress run-drupal-x Civibot should setup demos+tests for Drupal 9/10/etc run-backdrop Civibot should setup demos+tests for Backdrop labels Nov 25, 2026
@vingle

vingle commented Nov 25, 2026

Copy link
Copy Markdown
Contributor
image

ah thanks! (I think that's the third time I've forgotten - hopefully last)

@vingle

vingle commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Joomla testing:

This line:

body.com_civicrm.layout-default table .crm-sticky-header,
body.com_civicrm.layout-default table.crm-sticky-header {
--crm-menubar-bottom: 0;
}
is stopping this from working at body.crm-menubar-over-cms-menu. The sticky table header vanishes behind the civi menu.

I'd suggest changing that line to body.crm-menubar-below-cms-menu table.crm-sticky-header {--crm-menubar-bottom: 0;} - then it will keep it at zero for menu below, but use the JS-generated value for menu above.

This also works with wrapping menu items.

Comment on lines 84 to 88
table.crm-sticky-header > thead > tr {
position: sticky !important;
top: var(--crm-menubar-bottom, 0);
box-shadow: 0 2px 2px -1px #cfcec3;
z-index: 2;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is breaking the tables at viewports < 769px on all CMSs. Wrapping this in a media query should fix it. ie

@media (min-width: 768px) {
table.crm-sticky-header > thead > tr {
  position: sticky !important; 
  etc
}
}

@vingle

vingle commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

The only other built demo is for Backdrop - which works fine other than mobile viewport.

image

My guess is the other CMSs will work ok other than mobile, but maybe Drupal users will want to check this on some other admin themes.

…ixed

Prevents bogus --crm-menubar-bottom offsets on mobile viewports (where #civicrm-menu is hidden/vertical), when the menubar is hidden during resize, and when the menubar uses position: absolute (such as Joomla 4/5 below-cms-menu and Backdrop absolute admin bar). Removes the now-redundant Joomla Riverlea override that was breaking over-cms-menu.

Co-authored-by: Antigravity (Gemini) — reviewed PR feedback and implemented fix
Wraps table.crm-sticky-header sticky rules in @media (min-width: 768px) in both Riverlea and core CSS to avoid conflicting with Riverlea's mobile responsive table layout (display: contents below 768px) and keep small viewports uncluttered.

Co-authored-by: Antigravity (Gemini) — reviewed PR feedback and implemented fix
@colemanw

Copy link
Copy Markdown
Member Author

Thanks for the testing @vingle wrapping the sticky css in a media query is a good idea. I've done that.
And while I was in there, realized that the js which sets --crm-menubar-bottom was misbehaving on mobile, so I fixed that too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

master run-backdrop Civibot should setup demos+tests for Backdrop run-drupal-x Civibot should setup demos+tests for Drupal 9/10/etc run-wordpress Civibot should setup demos+tests for WordPress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants