Skip to content

Conversation

@alecgeatches
Copy link
Contributor

@alecgeatches alecgeatches commented May 19, 2025

Description

At present, using the tab key to select and use the Traffic Boost feature doesn't seem to select anything. With testing, most of the components support tab movement, but the :focus state wasn't being drawn. This PR mostly adds :focus states to ensure navigation via keyboard is visible. See the short demo at the bottom of this PR for how it looks now.

Motivation and context

This change improves accessibility and keyboard navigation.

How has this been tested?

Test locally, see video below.

Screenshots

Noodling around Traffic Boost menus with tab/shift-tab:

Screen.Recording.2025-05-19.at.1.08.18.PM.mov

Summary by CodeRabbit

  • Style

    • Improved focus outlines for links and select elements in the sidebar to enhance keyboard accessibility.
    • Updated the visual order of sidebar tabs so that the suggestions tab appears before the inbound links tab.
  • Refactor

    • Streamlined keyboard event handling for single link components to improve code clarity.

@alecgeatches alecgeatches requested a review from acicovic May 19, 2025 19:14
@alecgeatches alecgeatches self-assigned this May 19, 2025
@alecgeatches alecgeatches requested a review from a team as a code owner May 19, 2025 19:14
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 19, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (2)
  • build/content-helper/dashboard-page.asset.php is excluded by !build/**
  • build/content-helper/dashboard-page.js is excluded by !build/**

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

The updates include CSS modifications to improve focus visibility and tab ordering in the traffic boost sidebar, enhancing accessibility and layout. Additionally, a keyboard event handler in the single link component was refactored for clarity by introducing a named function, with no changes to the component’s logic or exports.

Changes

File(s) Change Summary
.../traffic-boost/sidebar/components/links-list/links-list.scss Updated focus styles for .traffic-boost-single-link and .page-selector select to add visible outlines and improve accessibility.
.../traffic-boost/sidebar/sidebar.scss Added explicit order properties to .suggestions-tab and .inbound-links-tab to control their visual order in the sidebar.
.../traffic-boost/sidebar/components/links-list/single-link.tsx Refactored keyboard event handling by introducing a named handleKeyDown function for clarity; no changes to logic or exports.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant SingleLinkComponent

  User->>SingleLinkComponent: KeyDown (Enter/Space)
  SingleLinkComponent->>SingleLinkComponent: handleKeyDown(event)
  alt Key is Enter or Space
    SingleLinkComponent->>SingleLinkComponent: Prevent default
    SingleLinkComponent->>SingleLinkComponent: Trigger click handler
  end
Loading

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (5)
src/content-helper/dashboard-page/pages/traffic-boost/sidebar/sidebar.scss (1)

199-205: Ensure keyboard focus order matches visual tab order.
While setting CSS order controls the visual arrangement of the .suggestions-tab and .inbound-links-tab, it does not affect the DOM order or the browser’s tabbing sequence. If the underlying markup order does not already reflect the intended navigation order, keyboard users may tab through elements in an unexpected sequence. Consider verifying that the DOM order aligns with these CSS orders or, if reordering the markup is not feasible, explicitly manage focus order (e.g., via tabindex) to maintain consistency.

src/content-helper/dashboard-page/pages/traffic-boost/sidebar/components/links-list/links-list.scss (2)

31-35: Prefer :focus-visible over :focus for keyboard-only outlines.
Using :focus-visible ensures the outline appears only on keyboard navigation (not when clicking with a mouse), reducing visual noise for mouse users. Example:

- & :focus {
+ & :focus-visible {
    outline: 2px solid var(--wp-admin-theme-color);
    outline-offset: -2px;
    box-shadow: none;
  }

83-86: Apply the same :focus-visible pattern to the <select> element.
Consistently use :focus-visible here as well:

- select:focus {
+ select:focus-visible {
    outline: 2px solid var(--wp-admin-theme-color);
    outline-offset: 1px;
  }
src/content-helper/dashboard-page/pages/traffic-boost/sidebar/components/links-list/single-link.tsx (2)

4-4: Align type imports with component imports for consistency.
You import forwardRef from @wordpress/element but bring in types from 'react'. To keep imports unified, either import types from @wordpress/element (it re-exports React types) or switch the runtime import to import { forwardRef } from 'react';.


59-64: Enhance cross-browser support for the Space key.
Some browsers (e.g., legacy IE/Edge) report e.key === 'Spacebar'. Consider guarding against both values:

- if ( e.key === 'Enter' || e.key === ' ' ) {
+ if ( e.key === 'Enter' || e.key === ' ' || e.key === 'Spacebar' ) {
     e.preventDefault();
     onClickHandler();
   }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 9a9dda3 and 7fa5993.

⛔ Files ignored due to path filters (4)
  • build/content-helper/dashboard-page-rtl.css is excluded by !build/**
  • build/content-helper/dashboard-page.asset.php is excluded by !build/**
  • build/content-helper/dashboard-page.css is excluded by !build/**
  • build/content-helper/dashboard-page.js is excluded by !build/**
📒 Files selected for processing (3)
  • src/content-helper/dashboard-page/pages/traffic-boost/sidebar/components/links-list/links-list.scss (2 hunks)
  • src/content-helper/dashboard-page/pages/traffic-boost/sidebar/components/links-list/single-link.tsx (3 hunks)
  • src/content-helper/dashboard-page/pages/traffic-boost/sidebar/sidebar.scss (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.{css,scss}`: "Perform a detailed review of the provided code with following key aspects in mind: - Review the SCSS code to ensure it is well-structured and adheres to best ...

**/*.{css,scss}: "Perform a detailed review of the provided code with following key aspects in mind:

  • Review the SCSS code to ensure it is well-structured and adheres to best practices.
  • Convert dimensions greater than or equal to 3px to rem units using the to_rem function.
  • Utilize variables for sizes and colors defined in src/content-helper/common/css/variables.scss instead of hardcoding values."
  • src/content-helper/dashboard-page/pages/traffic-boost/sidebar/sidebar.scss
  • src/content-helper/dashboard-page/pages/traffic-boost/sidebar/components/links-list/links-list.scss
`**/*.{js,ts,tsx,jsx}`: "Perform a detailed review of the provided code with following key aspects in mind: - Review the code to ensure it is well-structured and adheres to best ...

**/*.{js,ts,tsx,jsx}: "Perform a detailed review of the provided code with following key aspects in mind:

  • Review the code to ensure it is well-structured and adheres to best practices.
  • Verify compliance with WordPress coding standards.
  • Ensure the code is well-documented.
  • Check for security vulnerabilities and confirm the code is secure.
  • Optimize the code for performance, removing any unnecessary elements.
  • Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
  • Ensure each line comment concludes with a period.
  • Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
  • Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
  • src/content-helper/dashboard-page/pages/traffic-boost/sidebar/components/links-list/single-link.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: E2E against WordPress latest

@acicovic acicovic added this to the 3.19.0 milestone May 20, 2025
@acicovic acicovic added Feature: PCI Ticket/PR related to Content Intelligence Feature: Engagement Boost Ticket/PR related to Engagement Boost labels May 20, 2025
Copy link
Collaborator

@acicovic acicovic left a comment

Choose a reason for hiding this comment

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

Excellent, thank you!

@acicovic acicovic merged commit bcb6426 into add/traffic-boost May 20, 2025
39 checks passed
@acicovic acicovic deleted the fix/traffic-boost-tabbing branch May 20, 2025 08:11
@acicovic acicovic changed the title Minor fixes to tab visibility for accessibility Traffic Boost: Minor fixes to tab visibility for accessibility May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature: Engagement Boost Ticket/PR related to Engagement Boost Feature: PCI Ticket/PR related to Content Intelligence

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants