AI Disclosure

AI was used to update the MR.

Problem:

Default admin duplicates the header of the table and then uses JS to sticky it at the top of the page. This was necessary from ye ol' IE days, where we did not have tools like position: sticky. Note that Claro was modernized and no longer does this, yet default_admin was mostly derived from Gin, and still has the old method. which leads to problems such as focus order, etc.

Focus order issue

In the Default Admin theme, the keyboard navigation focus order in table headers is incorrect. This mirrors a bug identified in the Gin admin theme #3506338: Tabbing order in the table header is off.

When tabbing through a table (such as admin/content), the user is forced to cycle through the header columns twice. This appears to be caused by the theme rendering both a sticky and a regular table header, with both sets of elements remaining in the tab order. This results in a "lap of honor" where the focus circles back to the start of the header before finally moving into the table body.

Proposed Resolution:

We should remove the code that duplicates the table header and implement position: sticky, which replicates the current Claro behavior.

Steps to reproduce:

  • Navigate to a standard administrative table, such as admin/content.
  • Use the Tab key (or VO-arrow right in VoiceOver) to move through the table header.
  • Observe that after reaching the final column (e.g., "Updated"), the focus returns to the first column header instead of moving to the first row of data.

Screenshot of admin page tab order

Issue fork drupal-3583518

Command icon 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

mgifford created an issue. See original summary.

kentr’s picture

kentr’s picture

The issue summary of #3582351: [Meta] Clean up CSS within Admin theme has an item for completely removing the extra header.

14. For sticky tables, Gin completely duplicates the table header element, and then stickies it. This is the old way. Claro at one point moved to just using position: sticky. We should do that

mherchel’s picture

Note here, we need to remove the duplicate sticky table, which was added back when properties such as positition: sticky did not exist or work correctly.

Removing this functionality, and setting position: sticky should 1) fix the accessibility issue here, and 2) remove lots of unneeded complexity.

mherchel’s picture

Title: Tabbing order in the table header is off » Modernize table sticky header by using position: sticky
Issue summary: View changes

mherchel’s picture

Assigned: Unassigned » mherchel
Status: Active » Needs work
mortona2k’s picture

Sticky table headers are causing this issue in Default Admin: #3641375: Sticky table header covers caption

Default admin sticky headers cover caption

They are positioned wrong on mobile:

Default admin sticky table header mobile position wrong
__

Position: sticky doesn't work inside a horizontal scroll container, so javascript is still needed.

Claro works around this by breaking the layout:

Claro sticky table headers break layout
__

core/misc/tableheader.js has been removed.

Default Admin still overrides the file: https://git.drupalcode.org/project/drupal/-/blob/main/core/themes/defaul...
__

Lastly, the scroll container has a negative top margin and overlaps with anything above it. I'm not sure if this is a direct cause of the current sticky implementation, or something that might be reworked along with it.

Default admin table scroll wrapper negative top margin

This causing an issue in the Audit Files module: https://git.drupalcode.org/project/auditfiles/-/work_items/3418734

mortona2k’s picture

Issue summary: View changes
Status: Needs work » Needs review

MR !17498 fixed the caption overlap, but the sticky headers were hidden by the navigation top bar.

I used claude to fix the issues above. Verbose comments left in for review, but can be removed before merging.

A new js script is added to check if the table scrolls horizontally and handles the sticky position.

We can't have sticky headers and scrolling tables with css alone.
If the table does not scroll, it gets .is-sticky-native and the positioning js does not apply.
When javascript is disabled, sticky headers don't work to preserve horizontal scrolling.