Skip to content

Replace jquery.tableHeader.js with CSS position: sticky - #38207

Merged
mattwire merged 1 commit into
civicrm:masterfrom
colemanw:remove-tableheader
Nov 22, 2026
Merged

mattwire merged 1 commit into
civicrm:masterfrom
colemanw:remove-tableheader

Conversation

@colemanw

@colemanw colemanw commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Overview

This finally lets us remove an ancient script copied from Drupal6.
The js handled <thead class="sticky">, this replaces it with pure CSS.

cc @vingle

Co-authored-by: Antigravity (AI assistant) <noreply@google.com>
@civibot

civibot Bot commented Nov 22, 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 🔗

@colemanw

Copy link
Copy Markdown
Member Author

@vingle the old jquery.tableHeader.js was making a copy of the table header, putting it in a div.sticky-header and giving it a fixed position. Here I've switched our css to target the original thead, and deleted the js.

@vingle

vingle commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Thanks @colemanw - while I've not tested, the PR makes good sense.

If I understand right, it's similar to what @shaneonabike was proposing here: https://lab.civicrm.org/dev/core/-/work_items/5221 (which then got closed in favour of a broader tables WIP: https://lab.civicrm.org/extensions/riverlea/-/work_items/98). He did some work before that with a .crm-sticky class: #30180 - am assuming this won't clash with that? Or even better, supersedes it?

@colemanw

Copy link
Copy Markdown
Member Author

ACK @vingle good idea to look around at other implementations. Turns out we have 3:

  • .sticky The OG D6 javascript version.
    • Used in 35 core templates and 35 extensions in universe, BUT...
    • It has no crm- prefix
    • Most importantly, it's currently broken!. I can'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 needs 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 Shane 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 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:

  1. Move .crm-sticky-header css from searchKit to core/Riverlea
  2. Update the one use of .crm-sticky and delete it
  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 say we just delete it.

@mattwire
mattwire merged commit 934acf1 into civicrm:master Nov 22, 2026
1 check passed
@colemanw

Copy link
Copy Markdown
Member Author

@mattwire you merged this a few seconds before I posted my comment suggesting we not merge this.

@vingle can you review this please? #38215

@vingle

vingle commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

@mattwire - also ftr, asides from there being an active conversation 'not tested, the PR makes good sense' for me means need to still test. css in Civi can regularly read well but render oddly because of the size.. anything other than linting needs a visual check, which rn is a very manual process.

@colemanw - that's a big review… don't think it will be this week. Because of visual regressions with @shaneonabike's Dress Code sample I think it will take a bit of cross-CMS checking and the majority of the templates changed here dble checking. Given that, would it be worth doing a bunch of table-related changes together? Thinking of jfilter's side-scroll PR, and also the Bootstrap classes like .table-striped seem inconsistently used. Could also remove inline styling like cellpadding="0" cellspacing="0" border="0" which is now handled by css.

@mattwire

Copy link
Copy Markdown
Contributor

Apologies, this looked like a pretty simple change :-) We can always revert for now until there is time to test #38215 etc if necessary @vingle @colemanw

@vingle

vingle commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

@mattwire - I don't know if it needs reverting.

The main problem is this variable --crm-menubar-bottom is CMS-specific.. if the whole of .sticky has been broken then any problems across all the CMSs won't have been spotted:

To see what I mean, the demo here on Standalone set its at 40px, which looks good in Activity Search:

image

But in Joomla for some reason it's --crm-menubar-bottom: 106px; which floats the header in the middle of the tables:

image

Joomla was broken before this, just not as badly. WordPress and some Drupal admin themes will also behave oddly because the position of the Civi container from the top of the viewport isn't consistent across every cms - and position sticky as used here needs an offset from the top of the viewport to avoid hiding behind the top nav.

@colemanw
colemanw deleted the remove-tableheader branch November 23, 2026 13:03
@vingle

vingle commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

I've finally tested this in Joomla - it's fixed for Civi Menubar above the Joomla menubar - when before it wasn't working.

But if the menubar is moved to below the Joomla menubar, ie…

image

…then it's broken:

image

Two things are going wrong:

  • style="--crm-menubar-bottom: 106px;" is set in the html tag, but it's `style="--crm-menubar-bottom: 40px;" when the civi menu is at the top.
  • the civi menu is no longer fixed at the header, so the actual variable should be 0.

That can be fixed by (tho that's reseting other civi output so maybe a bit hacky):

body.crm-menubar-below-cms-menu {
    --crm-menubar-bottom: 0;
}

But not sure what it does on WordPress and the family of Drupal admin themes/menu bars… @colemanw which CMSs have you checked #38215 against?

@shaneonabike

shaneonabike commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Well my understanding is that there are specific settings for each CMS? Because we won't ever get a specific setting perfect for each. I recall this was fixed in WP or Drupal before by (me?) by using the actual WP menubar height.. but I would need to check that.

So you probably just need to add a specific fix for Joomla now, and then we can test the other CMSs?

@vingle

vingle commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

WordPress is fine…
Sandbox Drupal 10 (which uses Seven?) looks fine…
Backdrop is bad when the menubar is set to 'below' but that's nothing to do with this PR or sticky tables, it's Civi-wide:

image

So just Joomla / menu below… but worth double checking other Drupal admin themes.

@vingle

vingle commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@shaneonabike it's being set by crm.menubar.js#L536. There's then a bunch of css overrides of that to reset it to 0 / something else…

@vingle

vingle commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Was just about to PR the Joomla fix, but see there's already a fix for table.crm-sticky-header - presumably added when did the work on @shaneonabike's PR. So that should mean the change from .sticky to .crm-sticky-header in #38215 should fix this for Joomla.

@colemanw

Copy link
Copy Markdown
Member Author

@vingle I'm sorry for the miscommunication but I didn't mean for you to test this PR at all, it's superseded by #38215 which drops the broken .sticky and the 99.9% unused .crm-sticky in favor of the already-widely-used, .crm-sticky-header.
That PR doesn't introduce anything new to that class, so it will continue to work just as well as it did before (it's been in use for years on every CMS). Any bugs in it would be pre-existing and IMO shouldn't block that PR.

@vingle

vingle commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@colemanw - I know, I just wanted to finish testing this PR first as it would (and did) reveal issues with --crm-menubar-bottom - tho as you say that shouldn't be an issue any more because of the bigger PR…

There was another reason - because of PRs being merged before I've finished looking at them, and the arrival of LLM reviewing, I'm a little apprehensive to invest the time to setup the PR on a local Joomla to give it the test it needs (the other CMSs I think can be tested by using the Github action commands to build various CMS demo sites - that I really should make a note of those commands!).

@colemanw

Copy link
Copy Markdown
Member Author

@vingle I think no-one will be merging that other PR without your go-ahead. What can I do to help get it over the line? I've just uploaded a video from my WP site. I could build other local sites and post more videos if that would help.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants