Skip to content

Fix duplicate HTML IDs and missing form labels in modal blocks #2083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

obenland
Copy link
Member

@obenland obenland commented Aug 19, 2025

See #2069

Proposed changes:

  • Fix duplicate HTML IDs in remote-reply and follow-me modal blocks by using unique identifiers with wp_unique_id()
  • Add proper form labels with screen-reader-text class for all input fields to resolve WebAIM accessibility violations
  • Fix aria-controls attributes to reference actual modal title elements instead of non-existent IDs
  • Update render_modal() function to support unique modal title IDs

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  1. Create a post with comments enabled
  2. Add the remote-reply block to the post
  3. Add the follow-me block to the post
  4. View the post on the frontend
  5. Run HTML validation tool (like WebAIM) - should show no duplicate ID errors
  6. Test with screen reader - all inputs should have proper labels
  7. Verify modal accessibility with keyboard navigation

Before: HTML validation errors for duplicate IDs (profile-handle, remote-profile) and missing form labels
After: Clean HTML validation and proper accessibility labels

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch

Type

  • Fixed - for any bug fixes

Message

Fix duplicate HTML IDs and missing form labels in modal blocks

Resolves accessibility issues in remote-reply and follow-me blocks by:
- Using unique IDs with wp_unique_id() to prevent duplicate HTML IDs
- Adding proper form labels with screen-reader-text class
- Fixing aria-controls to reference actual modal title elements

Fixes invalid HTML validation errors and WebAIM accessibility violations.
@Copilot Copilot AI review requested due to automatic review settings August 19, 2025 21:36
@obenland obenland self-assigned this Aug 19, 2025
@obenland obenland requested a review from pfefferle August 19, 2025 21:36
@github-actions github-actions bot added [Block] Follow Me [Block] Remote Reply aka "Reply on the Fediverse", in the comment list [Focus] Editor Changes to the ActivityPub experience in the block editor labels Aug 19, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes accessibility and HTML validation issues in modal blocks by implementing unique IDs and proper form labels. It addresses duplicate HTML ID problems that could occur when multiple instances of remote-reply or follow-me blocks exist on the same page.

  • Uses unique block IDs to prevent duplicate HTML element IDs across multiple block instances
  • Adds proper form labels with screen-reader-text class for better accessibility
  • Updates aria-controls references to point to the correct modal title elements

Reviewed Changes

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

Show a summary per file
File Description
src/remote-reply/render.php Updates input IDs to use block-specific prefixes and adds form labels
src/follow-me/render.php Updates input IDs to use block-specific prefixes and adds form labels
includes/class-blocks.php Adds modal ID parameter and generates unique title element IDs
build/remote-reply/render.php Compiled version with same changes as src plus early return guard
build/follow-me/render.php Compiled version with same changes as src

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Added explicit import of the is_activitypub_request function in both build and src versions of remote-reply/render.php to ensure proper function resolution.
Added an empty href attribute to the remote profile anchor tag in render.php to ensure valid HTML structure and improve accessibility. The actual URL is still dynamically bound via data-wp-bind--href.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Follow Me [Block] Remote Reply aka "Reply on the Fediverse", in the comment list [Focus] Editor Changes to the ActivityPub experience in the block editor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants