Problem/Motivation
Some accessibility concerns about the use of sticky table headers were brought up in #3070558: Implement bulk operation designs.
@andrewmacpherson pointed out that the use of a sticky header obscures content. There are two categories of issues this causes:
- In a table such as admin/content users can can navigate to an items hidden beneath a sticky header, so there's no longer a visual indication of the item in focus.
- Speech control users may encounter a problem with "show numbers" functionality, which displays a number label for each control on the page. These labels would also be applied to items concealed by the sticky and cause confusion.
Steps to reproduce
In admin/content, get the page in a position where the header is sticky, then tab-navigate through the table. Note that items hidden underneath the sticky header can still be focused, but the item+focus state is not visible.
Proposed resolution
This issue was discussed with @rain. There was agreement that there are UX benefits to sticky headers (and potentially other sticky elements such as the one proposed in #3070558). While are several straightforward ways to address concern #1 (keyboard users) while retaining the benefits of Sticky navigation, this doesn't seem possible for addressing #2 (Speech control "show numbers"). @rain suggested adding a toggle that allows enabling/disabling of sticky headers. This would allow the subset of users adversely impacted by sticky headers to bypass that functionality.
Remaining tasks
Determine if this is an acceptable change to core
Review the patch
User interface changes
A new toggle button above tables with sticky headers.
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #42 | Screenshot 2024-07-24 at 15.40.10.png | 81.18 KB | simohell |
Issue fork drupal-3163765
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:
- 3163765-add-toggle
changes, plain diff MR !8235
- 3163765-add-option-to
changes, plain diff MR !8150
Comments
Comment #2
bnjmnmThis patch adds a disable sticky toggle, a video of it in use is also provided.
Comment #3
bnjmnmComment #4
bnjmnmComment #5
lauriiiComment #6
andrewmacpherson commentedWhere will the toggle be found?
What will the default state be?
Personally, I think a toggle is a "lipstick on a pig" approach, because we're presenting a UI with accessibility problems, then expecting users to turn on a more accessible version. That introduces a discoverability problem. It will be better if content is never obscured by sticky headers in the first place.
Somewhere else there's an issue about changing the page margins when a sticky header is used. (Or maybe it's an issue about the toolbar? It's the same problem either way.)
Comment #7
andrewmacpherson commentedOops, I failed to notice there was a movie attachment in #2. Now I see where the toggle is.
Having the toggle adjacent to the content which it controls is generally a good idea. The somewhat annoying thing is that by the time you realize you need the toggle, it's no longer in the viewport. So there's effort involved to get what you need; you need to back-track to find the control. There might also be a some discoverability and/or working memory aspects too; did you notice the control was available before scrolling?
This would be clearer if it was a checkbox, or
role="switch", rather than a button which changes it's name. The problem with the latter is that it conflates purpose-of-control with current state. For anything other than a very commonly-recognized toggle such as play/pause, a button which changes it's name can be confusing. A checkbox is a cleaner separation of name, role, and value. (Another problem is that some assistive tech doesn't pick up on the accessible name change; I think have some reference material bookmarked about this. I'm unsure about the current state of play.)FWIW, our "show/hide row weights" buttons also have this problem, and it isn't a good pattern to repeat. I think we have an issue about that already.
Comment #13
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #15
mgiffordSounds like this is largely affecting https://www.w3.org/WAI/WCAG22/Understanding/focus-visible.html
Comment #17
yash.rode commentedHi, I was trying to make the patch from #3163765-2: Add option to un-sticky table headers to benefit assistive tech users compatible with 11.x, but while trying to apply
tableheader.js's changes, I noticed thatTableHeaderis not getting initialised. Can someone tell me how to approach this? For now I have created a new instance of TableHeader which doesn't seem rightComment #19
bnjmnmTo understand why this might not be working Do a search for
sticky-enabled(the class Tableheader looks for to initialize) in the codebase and it's a pretty manageable 15 matches. One of them is this line in Claro that intentionally removes this class from tables.A
git blamewill show this was added in the following issue: #3362276: Use position: sticky for views sticky table header which updates Claro to use CSS for positioning sticky.Another means of narrowing this down would have been to use your browser dev tools to inspect the sticky element and see what is making it sticky.
Either way, it looks like the approach will need to be adjusted to account for changes to core in the 4+ years since the last patch was added.
So for non-Claro themes, Tableheader will need to be updated to make sticky toggle-able. Claro is using a different approach to making the header sticky, and it will require a different toggle implementation based on that.
Comment #20
yash.rode commentedI tried keeping/removing the `position-sticky` class from the table, which makes it sticky/non-sticky respectively. I will try to implement that solution.
Comment #21
yash.rode commentedHi, the current version of the MR works for all other themes, except Claro as discussed in #3163765-19: Add option to un-sticky table headers to benefit assistive tech users. I have the version of
tableheader.jswhich is working for Claro also, but there are few things that needs to sanitised in that, will get to that tomorrow. Posting that as a patch for now.Comment #22
yash.rode commentedThis is the working patch for Claro which encorporates suggestions from #3163765-7: Add option to un-sticky table headers to benefit assistive tech users,
but unfortunately #3439580: Make drupal.tableheader only use CSS for sticky table headers just got in, which makes all this of no use.
Comment #23
yash.rode commentedRe-created the tableheader.js for making the sticky optional. Added the sticky header checkbox before the sticky header.
need to be cleaned and use local storage to handle the page refresh.
Comment #24
bnjmnmPatch testing will be deactivated in 32 days so it's best to do all of this in Gitlab.
Currently none of these dependencies are used, but core/drupal probably should be used so Drupal behaviors are used instead of DomContentLoaded
Not translated
Was this a GPT suggestion? GPT loves DOMContent loaded 🙂. Drupal behaviors would be used for something like this
Since you're just getting the first match
document.querySelector()is cleanerThe theme function might be overridden and not have this selector. While it is ultimately up to the developer to make sure these things are in place, you have the return value 2 lines above and could reference whatever is returned by stickyHeaderCheckbox
Drupal uses arrow syntax
All this logic can be just one line by using toggle()
Comment #26
yash.rode commentedI am working on adding the test.
Comment #27
yash.rode commentedComment #28
bnjmnmThis is consuming quite a bit of space for a control that most users will be indifferent to.

The location "show row weights" button, while not perfect (as mentioned in #7) is probably a better option as it is less greedy while still being visible.
Comment #29
bnjmnmYep, you'll need to add some dummy content, the need for nodes to fill the table isn't justification to use a whole profile. Creating what you need can be done in a handful of lines with a loop that calls
$this->drupalCreateNode()enough times to fill the view.Comment #30
yash.rode commentedIt is not working for stark theme, I will have to debug that more to figure that out.
Comment #31
yash.rode commentedComment #32
smustgrave commentedSo tested out on the permissions page and not sure how I feel about it haha. I like the control it gives but also wonder if it should be a theme setting. "Allow users to toggle sticky headers" so if you don't really want it you could turn off.
Functionally though working as advertised.
Leaving in NR for additional feedback
Comment #33
pyrello commented+1 for theme setting.
Comment #35
smustgrave commentedCleaning up MR and patches some. Could we add the theme setting?
Comment #36
yash.rode commentedIt is mainly for the accessibility users, so it makes more sense for it to be just above the table instead of going to theme settings page and changing it there.
Comment #37
smustgrave commentedThen I may be a -1 for it as it feel kinda awkward with the current placement
Comment #38
bnjmnmI'm not sure a theme setting would work well here for a few reasons:
I mentioned the hide/show weights toggle in #28 as a table-specific A11y setting that has existed in Drupal core for some time without much objection. Were the positioning of the sticky toggle more similar to hide/show weights I suspect the awkwardness would be mitigated.
Comment #39
smustgrave commentedI'd agree with that statement too.
Comment #41
utkarsh_33 commentedAddressed feedbacks mentioned in #38.
Comment #42
simohell commentedThe current MR seems to add the checkbox twice on admin/content - once before and once after the toggle for in a narrow view toggling on and off the low priority column. The order of the two toggles is something to be decided. The toggle seems to be missing admin/content/blocks, admin/content/files or admin/content/media - the last of which also has an alternative grid-view that doesn't need one.
On permissions page the checkbox is also doubled, but there are no other controls in between.
I think we should have do both the toggles with similar implementation. Now one is a checkbox and the other is a button. Styling can then be decided per theme if one would like to use a pin-icon for sighted users etc.