Skip to content

Conversation

@joshunrau
Copy link
Collaborator

@joshunrau joshunrau commented Apr 19, 2025

Summary by CodeRabbit

  • New Features

    • Added optional validation hook (beforeSubmit) to forms, allowing custom asynchronous checks before submission.
    • Added support for custom button styles in forms.
    • Enhanced error message and fallback components with test IDs for improved testing.
    • Improved accessibility in number input fields by linking labels and inputs with unique IDs.
    • Added a new Storybook example demonstrating form error handling.
  • Bug Fixes

    • Improved handling and display of root form errors.
  • Style

    • Updated button styling to show pointer cursor on hover.
    • Refined dialog overlay animation timing and class order.
    • Removed slide animations from dialog content for a smoother experience.
  • Tests

    • Added tests for error fallback and form validation, including custom pre-submit logic.
  • Chores

    • Upgraded a dependency to the latest version.
    • Updated .gitignore for local development scripts.
  • Refactor

    • Simplified error accumulation and display logic in forms.
    • Updated translation function types to support partial language mappings.
  • Documentation

    • Added and updated Storybook stories for form components.
  • Revert

    • Removed obsolete CSS for border color compatibility with older Tailwind CSS versions.

@coderabbitai
Copy link

coderabbitai bot commented Apr 19, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This set of changes introduces enhancements and refinements across several components and configuration files. The Form component now supports a beforeSubmit async validation callback and customizable button styles, with corresponding updates to error handling and test coverage. The ErrorMessage component accepts a className prop and adds test IDs for improved testability. Dialog components receive animation and class order adjustments. The NumberFieldInput now links its label and input for accessibility. The translation function interface is updated for more flexible language mappings. Additional updates include a dependency bump, .gitignore improvements, and removal of a Tailwind CSS compatibility block.

Changes

File(s) Change Summary
.gitignore Added local/ to ignored directories, reformatted VScode comment.
package.json Updated @douglasneuroinformatics/libjs dependency from ^2.7.0 to ^2.8.0.
src/components/Button/Button.tsx Added cursor-pointer to button variant classes for explicit pointer cursor.
src/components/Dialog/DialogContent.tsx Removed slide-in/out animation classes; retained fade and zoom animations.
src/components/Dialog/DialogOverlay.tsx Reordered animation classes and added duration-200 to overlay.
src/components/ErrorFallback/ErrorFallback.tsx
src/components/ErrorFallback/ErrorFallback.spec.tsx
Added data-testid to ErrorFallback, reordered text classes, and introduced a new test for ErrorFallback rendering.
src/components/Form/ErrorMessage.tsx Added optional className prop, merged classes, and added test IDs to error messages.
src/components/Form/Form.stories.tsx Added WithError Storybook story with custom validation and error display.
src/components/Form/Form.test.tsx Added tests for beforeSubmit validation logic in the Form component.
src/components/Form/Form.tsx Added beforeSubmit async callback and customStyles props, improved error handling, and updated button styling logic.
src/components/Form/NumberField/NumberFieldInput.tsx Used useId to link label and input for accessibility.
src/i18n/types.ts Made language keys in TranslateFunction's translations parameter optional.
src/tailwind/globals.css Removed Tailwind v3 border color compatibility override.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Form
  participant beforeSubmit
  participant onSubmit

  User->>Form: Submit form
  Form->>Form: Validate with Zod schema
  alt Validation fails
    Form->>User: Show validation errors
  else Validation succeeds
    alt beforeSubmit provided
      Form->>beforeSubmit: Call with form data
      alt beforeSubmit returns error
        Form->>User: Show root error message
      else beforeSubmit returns success
        Form->>onSubmit: Call onSubmit with data
      end
    else beforeSubmit not provided
      Form->>onSubmit: Call onSubmit with data
    end
  end
Loading

Possibly related PRs

  • fix: more obvious hover effect for button #55: Both PRs modify the buttonVariants CSS class string in src/components/Button/Button.tsx to adjust button hover and cursor styles, indicating related changes to button styling.
  • closes #38 #39: Both PRs modify the src/components/Form/Form.tsx file but address different features: this PR adds beforeSubmit and custom styles, while closes #38 #39 adds state for delayed rendering.

Suggested reviewers

  • joshunrau

Poem

A rabbit hops through fields of code,
With buttons now that point and glow'd.
Forms check twice before they send,
And errors easier to apprehend.
Dialogs fade with subtle grace,
While stories and tests keep pace.
With every change, a garden grows—
Where software blooms, the rabbit knows! 🐇🌱


📜 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 ccb6115 and 5e1c044.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (14)
  • .gitignore (1 hunks)
  • package.json (1 hunks)
  • src/components/Button/Button.tsx (1 hunks)
  • src/components/Dialog/DialogContent.tsx (1 hunks)
  • src/components/Dialog/DialogOverlay.tsx (1 hunks)
  • src/components/ErrorFallback/ErrorFallback.spec.tsx (1 hunks)
  • src/components/ErrorFallback/ErrorFallback.tsx (1 hunks)
  • src/components/Form/ErrorMessage.tsx (1 hunks)
  • src/components/Form/Form.stories.tsx (1 hunks)
  • src/components/Form/Form.test.tsx (2 hunks)
  • src/components/Form/Form.tsx (8 hunks)
  • src/components/Form/NumberField/NumberFieldInput.tsx (3 hunks)
  • src/i18n/types.ts (1 hunks)
  • src/tailwind/globals.css (0 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • 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 generate docstrings to generate docstrings for 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.

@joshunrau joshunrau merged commit 1841c00 into main Apr 19, 2025
1 of 2 checks passed
@github-actions
Copy link

🎉 This PR is included in version 4.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants