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

fix(14063): fix some components focused states #98

Merged
merged 2 commits into from
Aug 29, 2024

Conversation

Natallia-Harshunova
Copy link
Contributor

@Natallia-Harshunova Natallia-Harshunova commented Aug 25, 2024

https://kontur.fibery.io/Tasks/Task/Fix-control-states-in-FE-library-18914

Summary by CodeRabbit

  • New Features

    • Improved focus styles across various components (Checkbox, Radio, SelectButton) using the :focus-visible pseudo-class to enhance accessibility and user experience.
  • Bug Fixes

    • Corrected onChange event handling for Radio components to ensure accurate value selection.

These updates aim to provide a cleaner interface for mouse users while offering essential visual cues for keyboard navigation, improving overall usability.

@Natallia-Harshunova Natallia-Harshunova requested a review from a team August 25, 2024 19:10
Copy link

coderabbitai bot commented Aug 25, 2024

Walkthrough

The changes involve modifications to the focus state handling across various UI components, specifically transitioning from the :focus pseudo-class to :focus-visible. This adjustment is applied to interactive elements such as buttons, checkboxes, radio buttons, and select buttons, enhancing accessibility by providing focus indicators primarily for keyboard navigation.

Changes

File Path Summary of Changes
.../typography.css Updated focus state from :focus to :focus-visible for interactive elements (input, select, button, a tags) to enhance accessibility.
.../Checkbox/style.module.css Changed focus state styles from &:focus to &:focus-visible for the Checkbox component to improve accessibility and reduce visual clutter.
.../Radio/style.module.css Updated focus state styling, changing &:focus to &:focus-visible, enhancing accessibility for keyboard navigation.
.../Select/components/SelectButton/style.module.css Revamped focus styles by replacing :focus and :active with :focus-visible for the SelectButton component, improving visual feedback during keyboard navigation.
.../Toggler/style.module.css Adjusted pseudo-class from :focus to :focus-visible in the toggle component to enhance user experience for keyboard users.

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant Button as Button
    participant Accessibility as Accessibility System

    User->>Button: Click or Focus
    alt Keyboard Navigation
        Button->>Accessibility: Trigger focus-visible
    else Mouse Click
        Button->>Accessibility: No focus-visible
    end
Loading

🐇 In the fields where bunnies hop,
Focus states make our UX pop!
With keys we dance, and outlines show,
Accessibility’s the way to go!
A cleaner look, a joyful cheer,
For all who navigate, come near! 🌸


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

Copy link

github-actions bot commented Aug 25, 2024

♻️ PR Preview 15634ad has been successfully destroyed since this PR has been closed.

🤖 By surge-preview

Copy link

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 5c7c909 and a9f1ec9.

Files selected for processing (6)
  • packages/default-theme/typography.css (1 hunks)
  • packages/ui-kit/src/Checkbox/style.module.css (1 hunks)
  • packages/ui-kit/src/Radio/Radio.fixture.tsx (1 hunks)
  • packages/ui-kit/src/Radio/style.module.css (1 hunks)
  • packages/ui-kit/src/Select/components/SelectButton/style.module.css (2 hunks)
  • packages/ui-kit/src/Toggler/style.module.css (1 hunks)
Additional comments not posted (6)
packages/ui-kit/src/Radio/style.module.css (1)

34-34: Approved: Focus-visible implementation enhances accessibility.

The change from &:focus to &:focus-visible is a significant improvement for keyboard navigation accessibility. This ensures that the focus styles are only applied when necessary, avoiding unnecessary visual clutter for mouse users.

packages/ui-kit/src/Checkbox/style.module.css (1)

28-28: Approved: Correct application of focus-visible for better accessibility.

Switching from &:focus to &:focus-visible in the Checkbox component is a crucial enhancement. It ensures that focus indicators are shown only during keyboard navigation, which is essential for accessibility and reduces visual noise for mouse users.

packages/ui-kit/src/Toggler/style.module.css (1)

22-22: Approved: Effective use of focus-visible for enhanced accessibility.

The modification to use :focus-visible instead of :focus for the toggle component is an excellent update. It ensures that the focus indication is only visible during keyboard navigation, which is a best practice for modern web accessibility.

packages/ui-kit/src/Radio/Radio.fixture.tsx (1)

26-27: Correct and clear handling of state management.

The changes in the onChange handlers ensure that the correct values are passed, improving the clarity and correctness of the state management. It's recommended to verify the integration of these changes with the rest of the application to ensure there are no unforeseen side effects.

The code changes are approved.

Run the following script to verify the integration:

packages/ui-kit/src/Select/components/SelectButton/style.module.css (1)

119-119: Enhanced accessibility and cleaner interface.

The transition to :focus-visible for the .selectBox and button elements enhances accessibility by providing focus indicators primarily for keyboard navigation. It's recommended to verify the visual consistency of these changes across different browsers to ensure a uniform user experience.

The code changes are approved.

Run the following script to verify the visual consistency:

Also applies to: 164-165

packages/default-theme/typography.css (1)

22-22: Improved accessibility with focus-visible.

The use of :focus-visible for input, select, button, and a elements enhances accessibility by ensuring that the outline color is only applied during keyboard navigation. It's recommended to verify the integration of these changes with the rest of the application to ensure there are no unforeseen side effects.

The code changes are approved.

Run the following script to verify the integration:

Verification successful

Verified integration of :focus-visible across the codebase.

The :focus-visible CSS rule has been consistently applied across various components, enhancing accessibility by providing clear visual indicators for keyboard navigation. The integration appears to be thorough and well-executed.

  • Files with :focus-visible implementation:
    • packages/default-theme/typography.css
    • packages/ui-kit/src/Toggler/style.module.css
    • packages/ui-kit/src/Radio/style.module.css
    • packages/ui-kit/src/Select/components/SelectButton/style.module.css
    • packages/ui-kit/src/Checkbox/style.module.css
    • packages/ui-kit/src/Button/style.module.css
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of the `:focus-visible` changes with the rest of the application.

# Test: Search for the usage of `:focus-visible`. Expect: Only occurrences of the new implementation.
rg --type css -A 5 $':focus-visible'

Length of output: 3598

@@ -19,7 +19,7 @@ input,
select,
button,
a {
&:focus {
&:focus-visible {
Copy link
Contributor

Choose a reason for hiding this comment

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

/* Apply outline only when the button is focused via keyboard (e.g., using Tab) */
button:focus {
    outline: none; /* Disable outline for all focus states */
}

button:focus-visible {
    outline: 2px solid #007BFF; /* Re-enable outline only for keyboard focus */
}

Copy link

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between a9f1ec9 and 15634ad.

Files selected for processing (4)
  • packages/default-theme/typography.css (1 hunks)
  • packages/ui-kit/src/Checkbox/style.module.css (1 hunks)
  • packages/ui-kit/src/Radio/style.module.css (2 hunks)
  • packages/ui-kit/src/Select/components/SelectButton/style.module.css (2 hunks)
Additional comments not posted (6)
packages/ui-kit/src/Radio/style.module.css (1)

33-35: LGTM!

The change to &:focus-visible enhances accessibility by providing focus indicators primarily for keyboard navigation.

The code changes are approved.

packages/ui-kit/src/Checkbox/style.module.css (1)

28-30: LGTM!

The change to &:focus-visible enhances accessibility by providing focus indicators primarily for keyboard navigation.

The code changes are approved.

packages/ui-kit/src/Select/components/SelectButton/style.module.css (2)

118-119: LGTM!

The change to &:focus-visible enhances accessibility by providing focus indicators primarily for keyboard navigation.

The code changes are approved.


164-165: LGTM!

The change to &:focus-visible enhances accessibility by providing focus indicators primarily for keyboard navigation.

The code changes are approved.

packages/default-theme/typography.css (2)

23-24: Ensure accessibility: Removing outline and box-shadow on focus

Removing the outline and box-shadow on focus can impact accessibility for users who rely on keyboard navigation. Ensure that this change does not negatively affect the user experience.

Verify that all interactive elements still provide a clear visual indication when focused using the keyboard.


26-27: Enhance accessibility: Use :focus-visible for keyboard navigation

The use of :focus-visible ensures that the outline is applied only when the element is focused via keyboard navigation, improving accessibility.

The code changes are approved.

@Natallia-Harshunova Natallia-Harshunova requested a review from a team August 28, 2024 07:02
@Natallia-Harshunova Natallia-Harshunova merged commit f89fef0 into v5 Aug 29, 2024
3 checks passed
@Natallia-Harshunova Natallia-Harshunova deleted the 18914-fix-control-states-in-fe-library branch August 29, 2024 09:19
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