Skip to content

Application Passwords: Render a row header in the AJAX row template#12690

Open
itzmekhokan wants to merge 1 commit into
WordPress:trunkfrom
itzmekhokan:fix/65707-app-password-ajax-th-header
Open

Application Passwords: Render a row header in the AJAX row template#12690
itzmekhokan wants to merge 1 commit into
WordPress:trunkfrom
itzmekhokan:fix/65707-app-password-ajax-th-header

Conversation

@itzmekhokan

Copy link
Copy Markdown

Tables extending WP_List_Table render the primary column as a <th scope="row"> element so screen readers can announce it as context when navigating the table vertically. The Application Passwords table did this for server-rendered rows but not for the JavaScript row template used when a password is created via AJAX, so the row header was missing until reload.

What the problem was:

  • On page load, the app-name cell is a <th scope="row"> (correct).
  • After creating a new application password via AJAX, every cell in the new row was a <td> — the <th> row header was missing.
  • The header only appeared after refreshing the page.

What the fix does:

  • Renders the primary column of print_js_template_row() as a <th scope="row"> element, mirroring WP_List_Table::single_row_columns().

Approach and why:

  • The AJAX row is produced verbatim from this PHP template, so the parity fix belongs here. single_row_columns() uses the same $tag/$scope logic; reusing it keeps the two rendering paths identical. No aria-label is added because the table does not override get_primary_column_aria_label(), so the server path emits none either — adding one would introduce a new mismatch.

Trac ticket: https://core.trac.wordpress.org/ticket/65707

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 4.8
Used for: Ticket analysis, tests implementation, and writing PR description. All changes were reviewed and validated by me.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Copilot AI review requested due to automatic review settings July 25, 2026 03:56

Copilot AI 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.

Pull request overview

Improves accessibility parity for the Application Passwords admin list table by ensuring the AJAX-rendered “new row” markup matches the server-rendered row structure, specifically by rendering the primary column as a row header (<th scope="row">) so assistive technologies get correct context without requiring a page reload.

Changes:

  • Update WP_Application_Passwords_List_Table::print_js_template_row() to render the primary column as <th scope="row"> instead of <td>.
  • Add a PHPUnit test to assert the JS template uses a <th scope="row"> for the primary column and <td> for non-primary columns.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/wp-admin/includes/class-wp-application-passwords-list-table.php Aligns the AJAX row template’s primary column markup with WP_List_Table::single_row_columns() by using <th scope="row">.
tests/phpunit/tests/admin/wpApplicationPasswordsListTable.php Adds regression coverage to ensure the JS template renders the primary column as a row header.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +38 to +42
$this->assertStringContainsString(
'<th class="name column-name has-row-actions column-primary" data-colname="Name" scope="row">',
$html,
'The primary column should be rendered as a <th scope="row"> row header.'
);
@github-actions

github-actions Bot commented Jul 25, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props khokansardar, mukesh27.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

$tag = $is_primary ? 'th' : 'td';
$scope = $is_primary ? ' scope="row"' : '';

printf( '<%1$s class="%2$s" data-colname="%3$s"%4$s>', $tag, esc_attr( $classes ), esc_attr( wp_strip_all_tags( $display_name ) ), $scope );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add translators comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks @mukeshpanchal27. I looked into this, and I don't think a translators comment applies on this line — could you double-check?

This printf() only assembles the opening tag:
printf( '<%1$s class="%2$s" data-colname="%3$s"%4$s>', $tag, esc_attr( $classes ), esc_attr( wp_strip_all_tags( $display_name ) ), $scope );
The %1$s–%4$s placeholders are filled by $tag (th/td), $classes, $display_name, and $scope — none of them is a gettext call, so there's no translatable string here for a translators comment to describe. (The change from %s to numbered placeholders is just to keep the format readable now that there are four arguments.)

Happy to add one if you were pointing at a different line — let me know.

Tables extending WP_List_Table use a `<th scope="row">` element as the row
header for the primary column so screen readers can announce it as context
when navigating the table vertically. WP_List_Table::single_row_columns()
renders this for server-generated rows, but the JavaScript template used
when a new application password is created via AJAX rendered every cell as a
`<td>`, leaving the row header missing until the page was reloaded.

Render the primary column of the JavaScript row template as a
`<th scope="row">` element, mirroring the server-rendered markup.

Fixes #65707.
See #32892.
@itzmekhokan
itzmekhokan force-pushed the fix/65707-app-password-ajax-th-header branch from 16231a6 to 4380271 Compare July 25, 2026 11:39
Copilot AI review requested due to automatic review settings July 25, 2026 11:39

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment on lines +41 to +45
$this->assertMatchesRegularExpression(
'/<th class="name column-name has-row-actions column-primary" data-colname="[^"]*" scope="row">/',
$html,
'The primary column should be rendered as a <th scope="row"> row header.'
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants