Skip to content
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

feat: Added focus ring for focus visible #37700

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

Conversation

albinAppsmith
Copy link
Collaborator

@albinAppsmith albinAppsmith commented Nov 26, 2024

Description

This PR adds focus ring for CTA's in the platform.

Fixes #37699

Automation

/ok-to-test tags="@tag.Sanity"

🔍 Cypress test results

Warning

Tests have not run on the HEAD 429e7b1 yet


Tue, 26 Nov 2024 17:10:06 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced focus state styling for the select component, improving visibility when active.
  • Bug Fixes

    • Improved accessibility and visual clarity of focus outlines across the application.
  • Chores

    • Removed outdated focus outline rules, allowing for a more streamlined styling approach.

Copy link
Contributor

coderabbitai bot commented Nov 26, 2024

Walkthrough

The pull request introduces several modifications to the CSS styles for the .ads-v2-select component and related styles. Key changes include adjustments to the outline-offset property, updates to CSS variables for outline properties, and the introduction of new styles for focus states. Additionally, some rules disabling focus outlines have been removed, allowing for improved visibility and clarity during user interactions. The overall structure of the CSS remains intact, focusing on enhancing accessibility and visual feedback for focused elements.

Changes

File Path Change Summary
app/client/packages/design-system/ads/src/Select/styles.css - Modified outline-offset from variable to -2px in .ads-v2-select.rc-select-focused.
- Removed --select-color-border in the same class.
- Added border-color: transparent in .ads-v2-select.rc-select-focused > .rc-select-selector.
app/client/packages/design-system/ads/src/__theme__/default/index.css - Updated CSS variables for outline properties:
--ads-v2-color-outline to var(--ads-v2-color-blue-300),
--ads-v2-border-width-outline to 2px,
--ads-v2-offset-outline to -2px.
- Added :focus-visible to .ads-v2-focus-ring for improved focus visibility.
app/client/src/index.css - Removed rules disabling outlines for focused elements, including the .ads-v2-select.rc-select-focused.

Possibly related PRs

  • chore: chat widget polish fixes #37124: The changes in the SegmentedControl.styles.tsx file involve CSS selectors and focus-visible outlines, which relate to the overall focus state styling improvements seen in the main PR for the .ads-v2-select.rc-select-focused class.

Suggested labels

Bug, Production, IDE Product, ok-to-test, Needs Triaging

Suggested reviewers

  • ApekshaBhosale
  • sagar-qa007

🎉 In the land of CSS, where styles do play,
Focus outlines now shine, brightening the way.
With colors and borders, so clear and so bold,
User interactions, a sight to behold!
A sprinkle of changes, a dash of delight,
In the world of design, everything feels right! ✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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

@github-actions github-actions bot added IDE Navigation Issues/feature requests related to IDE navigation, and context switching IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product Task A simple Todo labels Nov 26, 2024
@albinAppsmith
Copy link
Collaborator Author

/build-deploy-preview skip-test=true

@github-actions github-actions bot added the Enhancement New feature or request label Nov 26, 2024
Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/12025302772.
Workflow: On demand build Docker image and deploy preview.
skip-tests: . env: .
PR: 37700.
recreate: .

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

🧹 Outside diff range and nitpick comments (1)
app/client/packages/design-system/ads/src/__theme__/default/index.css (1)

242-244: LGTM! Consider documenting the focus ring variables.

The focus ring variables follow accessibility best practices. However, there's a TODO comment about focus issues across the platform.

Consider adding a comment block explaining the purpose and usage of these focus ring variables for better maintainability.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1295c6a and f303d56.

📒 Files selected for processing (3)
  • app/client/packages/design-system/ads/src/Select/styles.css (2 hunks)
  • app/client/packages/design-system/ads/src/__theme__/default/index.css (2 hunks)
  • app/client/src/index.css (0 hunks)
💤 Files with no reviewable changes (1)
  • app/client/src/index.css
🔇 Additional comments (3)
app/client/packages/design-system/ads/src/Select/styles.css (2)

53-53: LGTM: Focus ring offset implementation

The fixed -2px offset provides consistent focus indication across browsers, improving accessibility for keyboard users.


115-117: LGTM: Clean focus state implementation

Setting transparent border prevents double-border effect while maintaining the focus ring visibility. This is a good practice for accessible focus states.

app/client/packages/design-system/ads/src/__theme__/default/index.css (1)

255-258: LGTM! Verify browser compatibility for :focus-visible.

The focus ring implementation follows modern accessibility patterns. The use of !important is appropriate here to prevent focus ring suppression.

Let's verify browser support for the :focus-visible pseudo-class:

✅ Verification successful

Focus ring implementation is compatible with modern browsers

The codebase shows consistent focus ring implementation across components using :focus-visible with fallback .ads-v2-focus-ring class. The styles are properly scoped and use CSS custom properties for consistent theming.

Key findings from the codebase scan:

  • :focus-visible is used consistently in design system components
  • Proper outline styles with !important to prevent overrides
  • CSS custom properties for outline width, color and offset
  • No conflicting browser-specific focus styles found
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any browser-specific focus styles in the codebase
# that might conflict with the new implementation

# Search for any existing focus-related styles
rg -g '*.css' -i '(:focus|focus-|outline:)'

# Search for browser-specific focus style overrides
rg -g '*.css' -i '(-moz-|webkit-|ms-).*(focus|outline)'

Length of output: 125880

@@ -50,8 +50,7 @@
/* Focused */
.ads-v2-select.rc-select-focused {
outline: var(--ads-v2-border-width-outline) solid var(--ads-v2-color-outline);
outline-offset: var(--ads-v2-offset-outline);
--select-color-border: var(--ads-v2-colors-control-field-active-border);
outline-offset: -2px;
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Focus ring contrast needs improvement

The current focus ring uses --ads-v2-color-blue-300: #8bb0fa which may not provide sufficient contrast against light backgrounds like #fff used in the Select component. Consider using a darker blue shade (e.g., --ads-v2-color-blue-600: #2d6bf4) for better accessibility compliance.

  • app/client/packages/design-system/ads/src/__theme__/default/index.css: Update --ads-v2-color-outline to use a higher contrast color
  • app/client/packages/design-system/ads/src/Select/rc-styles.css: Multiple background colors (#fff, #ddd) need to be tested against the focus ring
🔗 Analysis chain

Verify focus ring contrast ratio

Please ensure the focus ring color (var(--ads-v2-color-outline)) provides sufficient contrast against all possible background colors for accessibility compliance.

Also applies to: 115-117

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the definition of --ads-v2-color-outline to verify contrast
rg --type css "ads-v2-color-outline|ads-v2-color-blue-300" -A 2

Length of output: 2365


Script:

#!/bin/bash
# Search for background colors that might be used with the focus ring
rg --type css "background|bg-color" app/client/packages/design-system/ads/src/Select/

Length of output: 1031


Script:

#!/bin/bash
# Search for color definitions in theme files to analyze contrast
rg --type css "color:|background-color:|bg-color:" app/client/packages/design-system/ads/src/__theme__/default/

Length of output: 1103


Script:

#!/bin/bash
# Check if there are any dark theme definitions
fd -e css -e ts -e js "dark" app/client/packages/design-system/ads/src/__theme__/

Length of output: 81

@albinAppsmith
Copy link
Collaborator Author

/build-deploy-preview skip-test=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/12027252268.
Workflow: On demand build Docker image and deploy preview.
skip-tests: . env: .
PR: 37700.
recreate: .

@albinAppsmith
Copy link
Collaborator Author

/build-deploy-preview skip-test=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/12035598494.
Workflow: On demand build Docker image and deploy preview.
skip-tests: . env: .
PR: 37700.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-37700.dp.appsmith.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request IDE Navigation Issues/feature requests related to IDE navigation, and context switching IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task] - Add focus ring to platform
1 participant