Skip to content

Added Landmark Location - #1028

Merged
SteveJonesDev merged 16 commits into
developfrom
steve/try/landmark-location
Jul 8, 2025
Merged

Added Landmark Location#1028
SteveJonesDev merged 16 commits into
developfrom
steve/try/landmark-location

Conversation

@SteveJonesDev

@SteveJonesDev SteveJonesDev commented Jun 24, 2025

Copy link
Copy Markdown
Member

This pull request introduces significant enhancements to the accessibility checker by adding landmark detection and highlighting functionality. The changes include updates to the database schema, backend logic, and frontend UI to support landmarks like headers, footers, and navigation regions. Below are the most important changes grouped by theme:

Database and Backend Enhancements:

  • Updated the database schema to include landmark and landmark_selector fields for storing landmark information in the edac_rules table. (admin/class-update-database.php, admin/class-update-database.phpR51-R52)
  • Modified the Insert_Rule_Data class to handle landmarks, adding landmark and landmark_selector parameters to the insert method and ensuring proper sanitization. (admin/class-insert-rule-data.php, [1] [2] [3]
  • Updated the REST API to capture and pass landmark data when inserting rule violations. (includes/classes/class-rest-api.php, includes/classes/class-rest-api.phpL383-R386)

Frontend Highlighting Improvements:

  • Added a highlightLandmark method to visually highlight landmarks on the frontend, including creating labels and using fallback strategies for landmark selection. (src/frontendHighlighterApp/index.js, src/frontendHighlighterApp/index.jsR901-R1090)
  • Introduced logic to clean up landmark highlights and labels when removing highlights. (src/frontendHighlighterApp/index.js, [1] [2]

UI and Styling Updates:

  • Updated the admin UI to display a new "Landmark" column in the rule records table. (admin/class-ajax.php, [1] [2]
  • Adjusted CSS to accommodate the new "Landmark" column in both labels and record rows. (src/admin/sass/accessibility-checker-admin.scss, [1] [2]

Landmark Detection Logic:

  • Implemented a utility to identify landmarks in the page scanner, including support for semantic tags and ARIA roles. (src/pageScanner/index.js, src/pageScanner/index.jsR13-R164)

Miscellaneous:

These changes collectively enhance the accessibility checker by improving its ability to detect, store, and highlight landmarks, making it easier for users to identify and address accessibility issues.

Fixes: https://linear.app/equalize-digital/issue/PRO-183/create-a-custom-database-column-to-store-the-issues-location
Fixes: https://linear.app/equalize-digital/issue/PRO-185/identify-the-landmark-location
Fixes: https://linear.app/equalize-digital/issue/PRO-184/add-a-location-column-to-the-details-panel-for-users-that-can-see-all
Fixes: #676
Fixes: #58
Fixes: #557

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added support for identifying and displaying the nearest semantic landmark (e.g., main, header, nav) associated with each accessibility issue.
    • Enabled highlighting of landmark regions on the front end via new links in the accessibility checker details.
  • User Interface

    • Updated the admin interface to include landmark information and links for each violation.
    • Adjusted the layout to accommodate the new landmark column.
    • Improved highlight styling and label display for selected elements and landmarks.
  • Tests

    • Updated test database schema to include landmark-related fields.

@coderabbitai

coderabbitai Bot commented Jun 24, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This update introduces support for associating accessibility violations with their nearest semantic landmarks in both backend storage and frontend display. It adds landmark data to database schemas, adjusts data insertion and retrieval logic, updates admin and frontend interfaces to display and highlight landmarks, and modifies related tests and styles.

Changes

File(s) Change Summary
accessibility-checker.php Updated EDAC_DB_VERSION constant from '1.0.3' to '1.0.4'.
admin/class-ajax.php Extended AJAX details output and SQL to include and display landmark and landmark_selector.
admin/class-insert-rule-data.php Updated insert method to accept and store optional landmark and landmark_selector parameters.
admin/class-update-database.php Modified database schema to add landmark and landmark_selector columns to the main table.
includes/classes/class-rest-api.php Passed landmark data to insert method in set_post_scan_results.
src/admin/sass/accessibility-checker-admin.scss Updated grid layout to add a fourth column for landmark display in admin UI.
src/frontendHighlighterApp/index.js Added support for highlighting landmarks via URL parameter and associated methods.
src/frontendHighlighterApp/sass/app.scss Added max-width and box-sizing styles to .edac-highlight-element-selected.
src/pageScanner/index.js Added logic to associate violations with nearest landmarks and generate selectors for them.
tests/phpunit/Admin/InsertRuleDataTest.php Updated test table schema to include new landmark columns.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FrontendHighlighter
    participant Backend (REST/API)
    participant Database

    User->>FrontendHighlighter: Loads page with edac_landmark param
    FrontendHighlighter->>FrontendHighlighter: Decodes selector, finds element
    FrontendHighlighter->>FrontendHighlighter: Highlights landmark, adds label

    User->>Backend (REST/API): Triggers scan or requests details
    Backend (REST/API)->>Database: Query/access with landmark columns
    Database-->>Backend (REST/API): Returns violations with landmark info
    Backend (REST/API)-->>User: Returns/display violations with landmark links
Loading

Assessment against linked issues

Objective Addressed Explanation
Add custom database columns to store issue location (PRO-183)
Identify and associate landmark location with accessibility violations (PRO-185)
Add a location (landmark) column to the details panel for users viewing all issues (PRO-184)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes were identified. All code changes relate directly to the objectives in the linked issues.

Suggested reviewers

  • pattonwebz

Poem

In the warren of code, a new trail appears,
Landmarks now guide us, dispelling old fears.
With highlights and columns, the pathways are clear,
Each bunny can find where the issues are near.
So hop on ahead—let’s make access sincere!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8a9e296 and 205a64c.

📒 Files selected for processing (1)
  • accessibility-checker.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • accessibility-checker.php
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: make-pot
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary of Changes

Hello @SteveJonesDev, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the accessibility checker's capabilities by integrating landmark region information into the violation reporting and storage mechanism. It introduces new database fields, updates backend data processing to handle this new information, and adds frontend logic to identify and associate violations with their respective semantic landmark elements, thereby improving the contextual understanding of accessibility issues.

Highlights

  • Database Schema Extension: The database schema for rule data has been updated to include new columns (landmark and landmark_selector) to store information about the semantic landmark region associated with a violation.
  • Backend Data Handling: The Insert_Rule_Data class and the REST API endpoint responsible for processing scan results have been modified to accept, sanitize, and persist the new landmark data when recording accessibility violations.
  • Frontend Landmark Detection: New JavaScript logic has been introduced to detect the closest semantic landmark (e.g., main, header, footer, nav) for a given HTML element and generate a unique CSS selector for it.
  • Enhanced Violation Reporting: The frontend scanning logic now includes the detected landmark type and its unique selector as part of the violation record, providing more contextual information for each identified accessibility issue.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces landmark location tracking to the accessibility checker, enhancing its functionality. The changes include PHP backend updates for data storage and JavaScript frontend enhancements for landmark detection. The review suggests improvements for code maintainability, robustness, and clarity.

Comment thread src/pageScanner/index.js
Comment on lines 113 to 128
item.violations.forEach( ( violation ) => {
if ( violation.result === 'failed' ) {
const selector = violation.node.selector;
const html = document.querySelector( selector )?.outerHTML;
const landmark = getLandmarkForSelector( selector );
violations.push( {
selector: violation.node.selector,
html: document.querySelector( violation.node.selector ).outerHTML,
selector,
html,
ruleId: item.id,
impact: item.impact,
tags: item.tags,
landmark: landmark.type,
landmarkSelector: landmark.selector,
} );
}
} );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Consider extracting the violation processing logic into a helper function to reduce code duplication and improve maintainability.

function processAndPushViolation(item, violationData, violations) {
    const selector = violationData.node.selector;
    const element = document.querySelector(selector);

    if (!element) {
        return;
    }

    const html = element.outerHTML;
    const landmark = getLandmarkForSelector(selector);

    violations.push({
        selector,
        html,
        ruleId: item.id,
        impact: item.impact,
        tags: item.tags,
        landmark: landmark.type,
        landmarkSelector: landmark.selector,
    });
}

rules.forEach((item) => {
    item.violations.forEach((violation) => {
        if (violation.result === 'failed') {
            processAndPushViolation(item, violation, violations);
        }
    });

Comment thread src/pageScanner/index.js
Comment on lines 132 to 145
item.incomplete.forEach( ( incompleteItem ) => {
const selector = incompleteItem.node.selector;
const html = document.querySelector( selector )?.outerHTML;
const landmark = getLandmarkForSelector( selector );
violations.push( {
selector: incompleteItem.node.selector,
html: document.querySelector( incompleteItem.node.selector ).outerHTML,
selector,
html,
ruleId: item.id,
impact: item.impact,
tags: item.tags,
landmark: landmark.type,
landmarkSelector: landmark.selector,
} );
} );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Consider extracting the violation processing logic into a helper function to reduce code duplication and improve maintainability.

item.incomplete.forEach((incompleteItem) => {
            processAndPushViolation(item, incompleteItem, violations);
        });
    }
});

Comment on lines +28 to +29
* @param string|null $landmark The landmark type (main, header, footer, nav), optional.
* @param string|null $landmark_selector The landmark selector, optional.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Consider adding scalar type hints to the $landmark and $landmark_selector parameters for better type safety and code clarity. Use ?string since they are nullable.

 * @param string|null $landmark The landmark type (main, header, footer, nav), optional.
 * @param string|null $landmark_selector The landmark selector, optional.

Comment thread includes/classes/class-rest-api.php Outdated
Comment thread src/pageScanner/index.js Outdated
@SteveJonesDev
SteveJonesDev marked this pull request as ready for review July 2, 2025 22:11
@github-actions

github-actions Bot commented Jul 2, 2025

Copy link
Copy Markdown
Contributor

The POT file has changed. Please update the POT file in your PR to keep translations up to date.
The updated POT file is available in the artifacts of this workflow run: https://github.com/equalizedigital/accessibility-checker/actions/runs/16036845678

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (4)
includes/classes/class-rest-api.php (1)

383-384: Use the null coalescing operator (??) for more concise and readable code.

$landmark          = $violation['landmark'] ?? null;
$landmark_selector = $violation['landmarkSelector'] ?? null;
admin/class-insert-rule-data.php (1)

28-29: Add scalar type hints to the landmark parameters for better type safety.

The past review comment about adding ?string type hints to the $landmark and $landmark_selector parameters is still valid.

Apply this diff to add the type hints:

- * @param string|null $landmark The landmark type (main, header, footer, nav), optional.
- * @param string|null $landmark_selector The landmark selector, optional.
+ * @param string|null $landmark The landmark type (main, header, footer, nav), optional.
+ * @param string|null $landmark_selector The landmark selector, optional.
  */
- public function insert( object $post, string $rule, string $ruletype, string $rule_obj, $landmark = null, $landmark_selector = null ) {
+ public function insert( object $post, string $rule, string $ruletype, string $rule_obj, ?string $landmark = null, ?string $landmark_selector = null ) {

Also applies to: 34-34

src/pageScanner/index.js (2)

138-145: Use CSS.escape() for class names to handle special characters.

The current implementation could fail if class names contain special CSS characters.

Apply this diff to properly escape class names:

 if ( current.className ) {
-	const classes = current.className.trim().split( /\s+/ )
+	const classes = current.className.trim().split( /\s+/ ).map(cls => CSS.escape(cls))
 		.filter( ( cls ) => ! cls.match( /^(wp-|js-|css-|generated-|dynamic-)/ ) ) // Filter out common dynamic classes
 		.slice( 0, 2 ); // Limit to first 2 classes for stability
 	if ( classes.length > 0 ) {
 		selector += `.${ classes.join( '.' ) }`;
 	}
 }

210-225: Extract violation processing logic to reduce code duplication.

The logic for processing violations is duplicated between regular violations and incomplete results.

Consider extracting the common logic into a helper function:

+function processViolationNode(node, item, violations) {
+	const selector = node.selector;
+	const element = document.querySelector(selector);
+	
+	if (!element) {
+		return;
+	}
+	
+	const html = element.outerHTML;
+	const landmark = getLandmarkForSelector(selector);
+	
+	violations.push({
+		selector,
+		html,
+		ruleId: item.id,
+		impact: item.impact,
+		tags: item.tags,
+		landmark: landmark.type,
+		landmarkSelector: landmark.selector,
+	});
+}

 rules.forEach( ( item ) => {
 	//Build an array of the dom selectors and ruleIDs for violations/failed tests
 	item.violations.forEach( ( violation ) => {
 		if ( violation.result === 'failed' ) {
-			const selector = violation.node.selector;
-			const html = document.querySelector( selector )?.outerHTML;
-			const landmark = getLandmarkForSelector( selector );
-			violations.push( {
-				selector,
-				html,
-				ruleId: item.id,
-				impact: item.impact,
-				tags: item.tags,
-				landmark: landmark.type,
-				landmarkSelector: landmark.selector,
-			} );
+			processViolationNode(violation.node, item, violations);
 		}
 	} );

 	// Handle incomplete results for form-field-multiple-labels only.
 	if ( item.id === 'form-field-multiple-labels' ) { // Allow incomplete results for this rule.
 		item.incomplete.forEach( ( incompleteItem ) => {
-			const selector = incompleteItem.node.selector;
-			const html = document.querySelector( selector )?.outerHTML;
-			const landmark = getLandmarkForSelector( selector );
-			violations.push( {
-				selector,
-				html,
-				ruleId: item.id,
-				impact: item.impact,
-				tags: item.tags,
-				landmark: landmark.type,
-				landmarkSelector: landmark.selector,
-			} );
+			processViolationNode(incompleteItem.node, item, violations);
 		} );
 	}
 } );

Also applies to: 229-242

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b98d6a and 2fd3252.

📒 Files selected for processing (9)
  • accessibility-checker.php (1 hunks)
  • admin/class-ajax.php (4 hunks)
  • admin/class-insert-rule-data.php (3 hunks)
  • admin/class-update-database.php (1 hunks)
  • includes/classes/class-rest-api.php (1 hunks)
  • src/admin/sass/accessibility-checker-admin.scss (2 hunks)
  • src/frontendHighlighterApp/index.js (5 hunks)
  • src/pageScanner/index.js (2 hunks)
  • tests/phpunit/Admin/InsertRuleDataTest.php (1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: SteveJonesDev
PR: equalizedigital/accessibility-checker#921
File: src/pageScanner/checks/linked-image-alt-present.js:43-50
Timestamp: 2025-04-15T02:30:38.897Z
Learning: In the Accessibility Checker plugin, accessibility rules are separated by specific concerns. For example, linked images have separate rules for checking: (1) missing alt attributes and (2) empty alt attributes. The rule `linked_image_alt_present` specifically checks for the presence of alt attributes on linked images, while a separate rule `img_linked_alt_empty` handles validation of empty alt attributes. Suggestions should respect this separation of concerns.
admin/class-ajax.php (5)
Learnt from: pattonwebz
PR: equalizedigital/accessibility-checker#927
File: src/pageScanner/checks/img-alt-missing-check.js:35-37
Timestamp: 2025-04-18T14:27:18.140Z
Learning: In the Accessibility Checker plugin, the img_alt_missing rule specifically checks for missing alt attributes on images and image inputs, while empty alt attributes are handled by a separate rule. Each accessibility concern is deliberately separated into individual rules.
Learnt from: SteveJonesDev
PR: equalizedigital/accessibility-checker#921
File: src/pageScanner/checks/linked-image-alt-present.js:43-50
Timestamp: 2025-04-15T02:30:38.897Z
Learning: In the Accessibility Checker plugin, accessibility rules are separated by specific concerns. For example, linked images have separate rules for checking: (1) missing alt attributes and (2) empty alt attributes. The rule `linked_image_alt_present` specifically checks for the presence of alt attributes on linked images, while a separate rule `img_linked_alt_empty` handles validation of empty alt attributes. Suggestions should respect this separation of concerns.
Learnt from: pattonwebz
PR: equalizedigital/accessibility-checker#927
File: src/pageScanner/checks/img-alt-missing-check.js:32-32
Timestamp: 2025-04-18T14:27:49.512Z
Learning: In the Accessibility Checker plugin, the img_alt_missing rule specifically checks for missing alt attributes (whether the attribute exists at all), while empty alt attributes (alt="") are handled by a separate rule. This separation of concerns is by design.
Learnt from: SteveJonesDev
PR: equalizedigital/accessibility-checker#921
File: src/pageScanner/checks/linked-image-alt-present.js:43-50
Timestamp: 2025-04-15T02:30:38.897Z
Learning: In the Accessibility Checker plugin, there are separate rules for different aspects of image accessibility. The rule `linked_image_alt_present` specifically checks for the presence of alt attributes on linked images, while a separate rule handles validation of empty alt attributes.
Learnt from: pattonwebz
PR: equalizedigital/accessibility-checker#881
File: src/pageScanner/checks/duplicate-form-label-check.js:51-55
Timestamp: 2025-04-08T21:45:57.372Z
Learning: The Accessibility Checker intentionally flags multiple IDs in aria-labelledby as a failure, even though it's technically allowed in the ARIA spec. This design decision was made because multiple IDs can cause confusion with some screen readers, and the tool aims to discourage any form of duplicate labelling to ensure maximum compatibility.
src/pageScanner/index.js (1)
Learnt from: SteveJonesDev
PR: equalizedigital/accessibility-checker#880
File: src/pageScanner/rules/video-present.js:3-3
Timestamp: 2025-04-08T21:36:48.803Z
Learning: In the accessibility-checker, the broad selector pattern in video-present.js (`'video, iframe, object, source, [src], [class], [role]'`) is intentional, as it allows the JavaScript evaluation function in video-detected.js to perform case-insensitive matching and sophisticated pattern detection that CSS selectors cannot replicate.
src/frontendHighlighterApp/index.js (1)
Learnt from: SteveJonesDev
PR: equalizedigital/accessibility-checker#880
File: src/pageScanner/rules/video-present.js:3-3
Timestamp: 2025-04-08T21:36:48.803Z
Learning: In the accessibility-checker, the broad selector pattern in video-present.js (`'video, iframe, object, source, [src], [class], [role]'`) is intentional, as it allows the JavaScript evaluation function in video-detected.js to perform case-insensitive matching and sophisticated pattern detection that CSS selectors cannot replicate.
🧬 Code Graph Analysis (2)
includes/classes/class-rest-api.php (1)
admin/class-insert-rule-data.php (2)
  • Insert_Rule_Data (17-156)
  • insert (34-155)
src/frontendHighlighterApp/index.js (2)
src/pageScanner/index.js (4)
  • selector (128-128)
  • role (49-49)
  • role (111-111)
  • tagName (82-82)
src/pageScanner/checks/has-ambiguous-text.js (1)
  • label (43-43)
🪛 Biome (1.9.4)
src/frontendHighlighterApp/index.js

[error] 934-934: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 1054-1057: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


[error] 1060-1062: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)

🔇 Additional comments (7)
accessibility-checker.php (1)

43-43: LGTM: Database version bump is appropriate.

The version increment from '1.0.3' to '1.0.5' correctly reflects the database schema changes that add landmark support.

tests/phpunit/Admin/InsertRuleDataTest.php (1)

40-41: LGTM: Test schema correctly updated to match production.

The addition of landmark and landmark_selector columns maintains proper alignment between test and production database schemas.

src/admin/sass/accessibility-checker-admin.scss (1)

624-624: LGTM: Grid layout properly updated for landmark column.

The addition of a fourth 125px column maintains visual consistency while accommodating the new landmark information in the admin interface.

Also applies to: 634-634

admin/class-update-database.php (1)

51-52: LGTM: Database schema correctly updated for landmark support.

The new nullable columns are appropriately typed - varchar(20) for landmark types and text for CSS selectors. The NULL constraints ensure backward compatibility with existing records.

includes/classes/class-rest-api.php (1)

386-386: LGTM: Landmark data properly passed to Insert_Rule_Data.

The integration with the enhanced Insert_Rule_Data::insert() method correctly provides the new landmark parameters, enabling storage of landmark context for accessibility violations.

admin/class-ajax.php (1)

308-308: LGTM! Well-implemented landmark display with proper security and accessibility.

The implementation correctly:

  • Retrieves landmark data from the database
  • Displays landmark information with appropriate links when both landmark and selector are available
  • Uses nonce for security in the landmark URLs
  • Includes proper ARIA labels and translatable strings for accessibility
  • Handles all edge cases (landmark with/without selector, no landmark)

Also applies to: 419-421, 469-494

src/frontendHighlighterApp/index.js (1)

906-1006: Excellent implementation of landmark highlighting with robust fallback strategies.

The implementation includes:

  • Proper error handling with try-catch blocks
  • Multiple fallback strategies for finding elements when the original selector fails
  • Well-styled landmark labels with appropriate positioning
  • Silent failure approach that doesn't disrupt the user experience
  • Proper cleanup integration with existing highlight removal

Comment thread src/frontendHighlighterApp/index.js
@github-actions

github-actions Bot commented Jul 3, 2025

Copy link
Copy Markdown
Contributor

The POT file has changed. Please update the POT file in your PR to keep translations up to date.
The updated POT file is available in the artifacts of this workflow run: https://github.com/equalizedigital/accessibility-checker/actions/runs/16040779184

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
src/frontendHighlighterApp/index.js (1)

1057-1069: Wrap switch case declarations in blocks to prevent scope issues.

Variables declared in switch cases can be accessed by other cases, which can lead to unexpected behavior.

Apply this diff to properly scope the variables:

 case 'section': {
-	// Check if section has accessible name
-	const hasAccessibleName = element.getAttribute( 'aria-label' ) ||
-		element.getAttribute( 'aria-labelledby' ) ||
-		element.querySelector( 'h1, h2, h3, h4, h5, h6' );
-	return hasAccessibleName ? 'Region' : 'Section';
+	{
+		// Check if section has accessible name
+		const hasAccessibleName = element.getAttribute( 'aria-label' ) ||
+			element.getAttribute( 'aria-labelledby' ) ||
+			element.querySelector( 'h1, h2, h3, h4, h5, h6' );
+		return hasAccessibleName ? 'Region' : 'Section';
+	}
 case 'form':
-	// Check if form has accessible name
-	const formHasAccessibleName = element.getAttribute( 'aria-label' ) ||
-		element.getAttribute( 'aria-labelledby' );
-	return formHasAccessibleName ? 'Form' : 'Form (unlabeled)';
+	{
+		// Check if form has accessible name
+		const formHasAccessibleName = element.getAttribute( 'aria-label' ) ||
+			element.getAttribute( 'aria-labelledby' );
+		return formHasAccessibleName ? 'Form' : 'Form (unlabeled)';
+	}
🧹 Nitpick comments (1)
src/frontendHighlighterApp/index.js (1)

902-1011: Consider refactoring for better maintainability and apply optional chaining.

The landmark highlighting functionality works correctly, but consider these improvements:

  1. Use optional chaining (as suggested by static analysis):
-if ( fallback && fallback.trim() ) {
+if ( fallback?.trim() ) {
  1. Consider breaking down this large method into smaller, focused functions for better maintainability:
    • decodeLandmarkSelector()
    • findLandmarkElement()
    • createLandmarkLabel()
    • positionAndShowLandmark()

The current implementation handles edge cases well and provides good fallback strategies for selector matching.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2fd3252 and 0510deb.

📒 Files selected for processing (6)
  • admin/class-ajax.php (4 hunks)
  • admin/class-insert-rule-data.php (3 hunks)
  • includes/classes/class-rest-api.php (1 hunks)
  • src/frontendHighlighterApp/index.js (5 hunks)
  • src/frontendHighlighterApp/sass/app.scss (1 hunks)
  • src/pageScanner/index.js (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/frontendHighlighterApp/sass/app.scss
🚧 Files skipped from review as they are similar to previous changes (4)
  • includes/classes/class-rest-api.php
  • admin/class-ajax.php
  • admin/class-insert-rule-data.php
  • src/pageScanner/index.js
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: SteveJonesDev
PR: equalizedigital/accessibility-checker#921
File: src/pageScanner/checks/linked-image-alt-present.js:43-50
Timestamp: 2025-04-15T02:30:38.897Z
Learning: In the Accessibility Checker plugin, accessibility rules are separated by specific concerns. For example, linked images have separate rules for checking: (1) missing alt attributes and (2) empty alt attributes. The rule `linked_image_alt_present` specifically checks for the presence of alt attributes on linked images, while a separate rule `img_linked_alt_empty` handles validation of empty alt attributes. Suggestions should respect this separation of concerns.
src/frontendHighlighterApp/index.js (2)
Learnt from: SteveJonesDev
PR: equalizedigital/accessibility-checker#880
File: src/pageScanner/rules/video-present.js:3-3
Timestamp: 2025-04-08T21:36:48.803Z
Learning: In the accessibility-checker, the broad selector pattern in video-present.js (`'video, iframe, object, source, [src], [class], [role]'`) is intentional, as it allows the JavaScript evaluation function in video-detected.js to perform case-insensitive matching and sophisticated pattern detection that CSS selectors cannot replicate.
Learnt from: pattonwebz
PR: equalizedigital/accessibility-checker#881
File: src/pageScanner/checks/duplicate-form-label-check.js:51-55
Timestamp: 2025-04-08T21:45:57.372Z
Learning: The Accessibility Checker intentionally flags multiple IDs in aria-labelledby as a failure, even though it's technically allowed in the ARIA spec. This design decision was made because multiple IDs can cause confusion with some screen readers, and the tool aims to discourage any form of duplicate labelling to ensure maximum compatibility.
🪛 Biome (1.9.4)
src/frontendHighlighterApp/index.js

[error] 934-934: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: make-pot
🔇 Additional comments (6)
src/frontendHighlighterApp/index.js (6)

35-35: LGTM! Parameter handling follows established patterns.

The landmark parameter addition is consistent with the existing URL parameter handling approach.


101-103: LGTM! Proper integration of landmark highlighting logic.

The conditional logic correctly handles the landmark parameter while maintaining backward compatibility with existing issue highlighting.


249-251: LGTM! Proper cleanup integration.

Adding landmark label cleanup when removing highlight buttons ensures a consistent clean state.


587-589: LGTM! Consistent cleanup logic.

Adding landmark label cleanup when removing selected classes maintains visual consistency.


1018-1073: LGTM! Comprehensive landmark type detection logic.

The method properly handles both ARIA roles and semantic HTML elements with appropriate fallbacks. The logic for distinguishing between labeled and unlabeled sections/forms is particularly well thought out.


1078-1090: LGTM! Thorough cleanup implementation.

The method comprehensively removes landmark labels, classes, and attributes, ensuring no visual artifacts remain after cleanup.

@SteveJonesDev
SteveJonesDev requested a review from pattonwebz July 3, 2025 05:28
@github-actions

github-actions Bot commented Jul 3, 2025

Copy link
Copy Markdown
Contributor

The POT file has changed. Please update the POT file in your PR to keep translations up to date.
The updated POT file is available in the artifacts of this workflow run: https://github.com/equalizedigital/accessibility-checker/actions/runs/16051838392

@github-actions

github-actions Bot commented Jul 3, 2025

Copy link
Copy Markdown
Contributor

The POT file has changed. Please update the POT file in your PR to keep translations up to date.
The updated POT file is available in the artifacts of this workflow run: https://github.com/equalizedigital/accessibility-checker/actions/runs/16056342537

@github-actions

github-actions Bot commented Jul 3, 2025

Copy link
Copy Markdown
Contributor

The POT file has changed. Please update the POT file in your PR to keep translations up to date.
The updated POT file is available in the artifacts of this workflow run: https://github.com/equalizedigital/accessibility-checker/actions/runs/16056550267

@pattonwebz pattonwebz left a comment

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.

I have been testing this as part of further work (I based from this for the selector PR) and found no major blocking issues. Approving.

As a note in the PR I branched from here to create I made a few tweaks:

  • extracted some logic to reusable helper for processing violations
  • updated the rulecheck part of the query to also update landmark and the selectors when it is flagging an unchanged rule (the location might still have changed even if the markup hasn't).

@SteveJonesDev
SteveJonesDev merged commit 1bb8760 into develop Jul 8, 2025
18 checks passed
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.

Add a location column that displays location of code snippet/issue POC: Issue Location Improved clarity on error names

2 participants