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: adding aria-live region on error #66

Merged
merged 5 commits into from
Nov 22, 2023

Conversation

aversini
Copy link
Collaborator

@aversini aversini commented Nov 22, 2023

Summary by CodeRabbit

  • New Features

    • Enhanced TextInput component with live error messaging and aria-invalid attribute for improved accessibility.
  • Refactor

    • Removed unused RAW_CLASSNAME constant and related class assignment logic.
    • Centralized external dependencies management for Vite configurations.
  • Style

    • Updated asset size constraints in bundlemon.config.cjs for better performance monitoring.
  • Tests

    • Added new test cases for TextInput component to validate accessibility features.
  • Chores

    • Updated ESLint configuration for better code quality enforcement.

Copy link

coderabbitai bot commented Nov 22, 2023

## Walkthrough

The changes across the project involve enhancing accessibility in UI components, specifically the `TextInput` component, by adding live region functionality and ARIA attributes. The project's build and lint configurations have been updated, with adjustments to asset size constraints and the centralization of external dependencies. ESLint rules have been modified for better code quality, and several configuration files have been updated to disable the "no-undef" rule, indicating a shift in linting strategy.

## Changes

| File(s) | Change Summary |
| --- | --- |
| `packages/ui-components/src/common/constants.ts` | Removed export of `RAW_CLASSNAME` constant. |
| `packages/ui-components/src/components/TextInput/TextInput.tsx` | Added `LiveRegion` import, `liveErrorMessage` variable, `aria-invalid` attribute, and `LiveRegion` component for error handling. |
| `packages/ui-components/src/components/TextInput/__tests__/TextInput.test.tsx` | Updated tests for class name expectations and added accessibility-related test cases. |
| `packages/ui-components/src/components/TextInput/utilities.ts` | Removed `RAW_CLASSNAME` usage, updated function signatures and logic for class assignment based on `raw` parameter. |
| `bundlemon.config.cjs` | Updated asset size constraints and added `maxPercentIncrease` for `index.js` and `style.css`. |
| `packages/ui-components/vite.config.ts` | Added `react-dom` and `react-dom/server` to external dependencies. |
| `.eslintrc.cjs` | Added root definition, extended configurations, ignore patterns, TypeScript parser, new plugins, and modified rules. |
| `configuration/eslint-rules/*.cjs` | Disabled "no-undef" eslint rule in various ESLint rule configuration files. |
| `configuration/lint-staged.config.cjs` | Added comment to disable "no-undef" eslint rule. |
| `configuration/vite.common.js` | Added `externalDependencies` array with project dependencies. |
| `packages/bundlesize/vite.config.ts` | Imported `externalDependencies` from common configuration to replace hardcoded dependencies. |

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

Copy link

bundlemon bot commented Nov 22, 2023

BundleMon

Files updated (1)
Status Path Size Limits
assets/index.js
5.45KB (+484B +9.49%) 10KB
Unchanged files (2)
Status Path Size Limits
assets/style.css
3.25KB 4KB
index.html
316B 2KB

Total files change +484B +5.54%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

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.

Review Status

Actionable comments generated: 0

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 32cb46b and 7b4817d.
Files selected for processing (4)
  • packages/ui-components/src/common/constants.ts (1 hunks)
  • packages/ui-components/src/components/TextInput/TextInput.tsx (4 hunks)
  • packages/ui-components/src/components/TextInput/tests/TextInput.test.tsx (2 hunks)
  • packages/ui-components/src/components/TextInput/utilities.ts (4 hunks)
Files skipped from review due to trivial changes (1)
  • packages/ui-components/src/common/constants.ts
Additional comments: 11
packages/ui-components/src/components/TextInput/__tests__/TextInput.test.tsx (3)
  • 44-48: The test case correctly checks for an empty class name for a raw text input with no styling. This aligns with the refactoring changes mentioned in the summary.

  • 79-95: This test case verifies the presence of ARIA attributes when an error message is rendered, which is crucial for accessibility. It ensures that aria-invalid is set to true and that aria-describedby contains the correct references. This is a good practice for accessibility testing.

  • 97-114: The test case for the live region update is well-implemented. It checks the aria-live attribute and the content of the live region before and after a specified delay. This ensures that the live region is updated correctly, which is important for screen reader users to receive timely feedback.

packages/ui-components/src/components/TextInput/TextInput.tsx (4)
  • 2-4: The import of LiveRegion is correctly added to support the new accessibility features. Ensure that the LiveRegion component is properly tested in the test suite.

  • 27-28: The liveErrorMessage variable concatenates the name and helperText, which is a good approach for creating descriptive error messages for screen readers. However, ensure that the name is user-friendly and appropriate for being read aloud by assistive technologies.

  • 58-58: The use of the aria-invalid attribute when there is an error is a good practice for accessibility, as it helps users of assistive technologies identify fields with errors.

  • 77-79: The LiveRegion component is correctly implemented to announce the liveErrorMessage. It's important to ensure that the delay and politeness level are appropriate and tested for the user experience.

packages/ui-components/src/components/TextInput/utilities.ts (4)
  • 66-75: The getTextInputHelperTextClasses function now correctly handles the raw parameter to conditionally return undefined if raw is true. This change aligns with the pull request's goal to refactor the code to control styling through a boolean parameter.

  • 87-93: The getTextInputClasses function has been updated to include the raw parameter and conditionally assign undefined to wrapper. This change is consistent with the refactoring goal mentioned in the pull request summary.

  • 87-99: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [95-108]

The getTextInputClasses function now uses the raw parameter to conditionally assign undefined to input and wrapper. This is a good use of the clsx library to manage conditional class names and supports the refactoring effort to remove the dependency on the RAW_CLASSNAME.

  • 110-114: The topLabel variable is correctly set to undefined when raw is true, and the helperText variable is updated to call getTextInputHelperTextClasses with the new error and raw parameters. This maintains consistency with the new approach to handling styles.

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.

Review Status

Actionable comments generated: 0

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 7b4817d and 76ca7e1.
Files selected for processing (2)
  • bundlemon.config.cjs (1 hunks)
  • packages/ui-components/vite.config.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • packages/ui-components/vite.config.ts
Additional comments: 2
bundlemon.config.cjs (2)
  • 9-13:
    The maximum size for "assets/index.js" has been reduced significantly from "60kb" to "10kb". Ensure that this change is intentional and that the current size of "assets/index.js" complies with the new limit to avoid build failures.

  • 16-18:
    A maximum percent increase constraint of 5% has been added for "assets/style.css". Verify that this new constraint aligns with the project's performance goals and that the current size of "assets/style.css" is within acceptable limits.

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.

Review Status

Actionable comments generated: 0

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 76ca7e1 and 9341605.
Files selected for processing (9)
  • .eslintrc.cjs (1 hunks)
  • bundlemon.config.cjs (2 hunks)
  • configuration/eslint-rules/best-practices.cjs (1 hunks)
  • configuration/eslint-rules/possible-errors.cjs (1 hunks)
  • configuration/eslint-rules/variables.cjs (1 hunks)
  • configuration/lint-staged.config.cjs (1 hunks)
  • configuration/vite.common.js (1 hunks)
  • packages/bundlesize/vite.config.ts (2 hunks)
  • packages/ui-components/vite.config.ts (2 hunks)
Files skipped from review due to trivial changes (6)
  • configuration/eslint-rules/best-practices.cjs
  • configuration/eslint-rules/possible-errors.cjs
  • configuration/eslint-rules/variables.cjs
  • configuration/lint-staged.config.cjs
  • packages/bundlesize/vite.config.ts
  • packages/ui-components/vite.config.ts
Additional comments: 5
configuration/vite.common.js (1)
  • 1-9: The addition of the externalDependencies array centralizes the management of external dependencies for the build process, which is a good practice for maintainability and consistency across different configuration files.
.eslintrc.cjs (1)
  • 1-25: - The ESLint configuration has been updated to include new plugins and rules, which should help maintain code quality and consistency. Ensure that the team is aware of these changes and that they understand the new rules, especially the implications of disabling the @typescript-eslint/no-explicit-any rule, which could lead to less type-safe code.
  • Verify that the ignorePatterns are correctly ignoring the intended files and directories, and that no necessary files are being excluded from linting.
  • Confirm that the new plugins "react-refresh" and "simple-import-sort" are installed and properly configured in the project's package.json.
  • The addition of custom rule files (best-practices.cjs, possible-errors.cjs, and variables.cjs) suggests a move towards a more tailored linting setup. Ensure that these files are present at the specified paths and contain the expected rule configurations.
  • The root property correctly indicates that this is the root ESLint configuration, which is important for projects with nested configurations.
bundlemon.config.cjs (3)
  • 1-1: The comment to disable the "no-undef" ESLint rule is present, but it's important to ensure that this rule is disabled for a valid reason and that it does not lead to unidentified global variables being used in the codebase.

  • 13-15: The maxSize for "assets/index.js" has been significantly reduced from "60kb" to "10kb". This is a substantial decrease and could potentially break the build if the current size exceeds this new limit. Verify that the current size of "assets/index.js" is within this new constraint and that the maxPercentIncrease of 5 is appropriate.

  • 18-20: Similarly, the maxSize for "assets/style.css" has been set to "4kb" with a maxPercentIncrease of 5. Ensure that the current size of "assets/style.css" complies with this new limit and that the maxPercentIncrease is suitable for the project's needs.

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.

Review Status

Actionable comments generated: 0

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 9341605 and 5303b50.
Files selected for processing (1)
  • bundlemon.config.cjs (2 hunks)
Additional comments: 2
bundlemon.config.cjs (2)
  • 1-1: The comment to disable the "no-undef" ESLint rule is correctly placed at the top of the file. However, ensure that this rule is intentionally disabled and that it does not lead to any unintended consequences in the codebase.

  • 13-14: The maximum size for "assets/index.js" has been reduced significantly from "60kb" to "10kb". Confirm that this new size constraint is realistic and that the current size of "assets/index.js" complies with this updated limit to avoid build failures.

@aversini aversini merged commit 5a52cb9 into main Nov 22, 2023
6 checks passed
@aversini aversini deleted the feat-adding-aria-live-region-on-error branch November 22, 2023 15:34
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.

1 participant