Problem/Motivation
The `drupal.tableheader` library provided a way to make table header sticky using JS when IE11 didn't have support for `position:sticky`.
Now that Drupal doesn't support IE11, we can remove the JS workaround and use `position:sticky` instead.
Related issues:
- #3362276: Use position: sticky for views sticky table header
- #590328: tableheader.js should give sticky-header table the same class as original table
Steps to reproduce
Proposed resolution
- ✅ Remove
tableheader.js - ✅ Add
`sticky-header`class to tables if`#sticky`is`true`for the table. - ✅ Add CSS to set
`position:sticky`for`.sticky-header thead` - ✅ Update
`drupal.tableheader`to include this css - ✅ Add/update tests
Remaining tasks
N/A
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Release notes snippet
Sticky table headers are now implemented with pure CSS instead of JavaScript.
Claro's custom implementation of sticky table headers which was already using pure CSS, has been removed and now relies on the default implementation.
Themes that heavily customise the sticky tableheaders markup, CSS, or JavaScript may need to update, or may be able to remove overrides if they were implementing a CSS-only solution similar to Claro's.
| Comment | File | Size | Author |
|---|
Issue fork drupal-3439580
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
dipakmdhrm commentedComment #3
dipakmdhrm commentedComment #4
dipakmdhrm commentedComment #5
dipakmdhrm commentedComment #7
dipakmdhrm commentedIt's fascinating that `position:sticky` replaces ~450 lines of code.
Things IE made developers do.
Comment #8
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue.
While you are making the above changes, we recommend that you convert this patch to a merge request. Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)
Comment #9
dipakmdhrm commentedThanks mr. needs-review-queue-bot. MR created.
Comment #10
bramdriesenDon't think this is good to go. You can't remove and deprecate at the same time.
Comment #11
dipakmdhrm commentedI've created an MR which should be better implemented than the patch.
The MR deprecates the `drupal.tableheader` library but removes the associated JS files, PHP code & text, and adds the css for sticky position.
That's not a bad idea.
Comment #12
dipakmdhrm commentedComment #14
dipakmdhrm commentedReady for review for 10.3.x
Comment #15
dipakmdhrm commentedDO NOT USE THIS PATCH
Comment #16
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #17
catchThe MR should target 11.x, it will be backported to 10.3.x from there. Couple of extra comments on the MR. This looks great in general, so much code to get rid of.
Comment #19
catchSmall metadata change - putting this into JavaScript because it's mostly about getting rid of JavaScript, might be questionably but close to that than theme system. Also re-titling for the new proposed solution.
Will need an issue summary update to match the new solution as well as a change record.
Comment #20
dipakmdhrm commentedComment #21
dipakmdhrm commentedComment #22
bramdriesenMaking the title easier to read
Comment #23
catchOne comment on the MR - because stable9 is there for backwards compatibility, we should probably add the new class and retain the old class instead or replacing. Otherwise this looks great to me!
Comment #24
balagan commentedJust rerolled patch #15 for D10.2.5.
Now that I have realized, that there are problems with this patch, I see the comment "Do not use this patch" at #15. So please ignore this too
Comment #25
dipakmdhrm commentedPatch re-rolled for Drupal 10.2.5
Comment #29
dipakmdhrm commentedTests for this should now hopefully pass for 11.x branch after the changes from this issue were merged in the MR branch.
Comment #30
shriaasTested with Drupal 11.x
The header is sticky on scroll(see the attached video).
+1 for RTBC
Comment #31
balagan commentedReroll of patch in https://www.drupal.org/project/drupal/issues/3439580#comment-15549200 for D 10.2.6
Comment #32
nicxvan commentedThis looks good to go, I updated the summary to be clearer.
Tests are passing and the video confirms it is working as expected as well.
The feedback on the MR has been addressed as well so I think it is ready.
Comment #33
nicxvan commentedForgot to mention I also reviewed the change record which looks good too!
Comment #34
nod_why the class name change? looks like it wouldn't cause a problem to use the
sticky-enabledclass to apply the css instead of creating a new one.Comment #35
catchThe original js adds the
sticky-headerclass, and this is what the existing CSS targets, so it's not actually creating a new class.core/modules/system/css/components/sticky-header.module.css
Comment #36
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #37
dipakmdhrm commentedThe patch in #31 is retroactively made for a specific version of D10.
The MR's still work for the issue.
Comment #38
nod_hiding patch to prevent the bot from messing with the issue
@#35 thanks for the details, all good then!
Comment #39
dipakmdhrm commented@nod_ @catch: We're now at beta for D11. Does that mean we now need to adjust the change record & deprecation to target 11.1 & 12 instead of 10.3 & 11?
Comment #40
catchIt will either need to be 11.1 for removal in 12 or 10.4 for removal in 12 depending on whether we backport this to 10.4 or not. I am not entirely sure if we would or not - it might be useful for themes that want to override the component to backport this to keep things in sync, but it's otherwise going to be quite a transparent change for most sites I would think which could be an argument for or against a backport. Will get an opinion or two from other committers.
Comment #41
dipakmdhrm commentedAny chance to do a d11-beta2 to avoid all this? :P
Comment #42
nod_let's get this in, risk is low
Comment #51
nod_Committed and pushed to 11.x
Comment #52
dipakmdhrm commentedWooo wooo yay!!!
Comment #53
nod_fixing issue credits
Comment #54
grimreaperHi,
Glad to see JS features made available with CSS only!
Sorry to arrive after the party, but in https://git.drupalcode.org/project/drupal/-/blob/10.3.x/core/modules/vie...
Should the
(JavaScript)be removed too?Comment #55
catch@GrimReaper - good find, could you open follow-up issue for fixing that text?
Comment #56
grimreaperThanks @catch.
I am on it :)
Comment #57
grimreaperFollow up issue created: #3451738: Remove JavaScript from Views configuration form now that it is only CSS
MR created and pipeline green, ready for review.
Comment #58
catchComment #60
boulaffasae commentedHi,
After this change, a lot of people seems to run into this issue
Is there any solution for it ?
Thank you