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(input validation): fields are accepted infinity digits, form added #2235

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DemaPy
Copy link
Contributor

@DemaPy DemaPy commented Mar 16, 2025

PR Description

Making input fields validation work as supposed previously.

Issue

Copy link

coderabbitai bot commented Mar 16, 2025

📝 Walkthrough

Walkthrough

The pull request updates the PictureOptions and PictureSection components by introducing a unified form submission handler, modified input attributes, and refined event handling. PictureOptions now wraps its content in a form, utilizes default values, and accepts a new prop for controlling a popover. PictureSection adds state management for the popover using an isOpen flag and a handleOpen function. Additionally, the ResumeStore is enhanced with a new setValues method that enables batch updates via lodash with a debounced state update trigger.

Changes

File(s) Change Summary
apps/client/src/pages/…/picture/options.tsx and apps/client/src/pages/…/picture/section.tsx Refactored PictureOptions to include a form submission handler (handleFormSubmit), updated input fields (using defaultValue and name attributes), and revised aspect ratio/border radius updates; Updated PictureSection by introducing an isOpen state and handleOpen function to control a popover, and modified the exported component interface to accept a handleOpen prop.
apps/client/src/stores/resume.ts Added a new setValues method to ResumeStore for batch updating resume data using lodash’s _set and triggering a debounced state update.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant FO as PictureOptions Form
    participant RS as ResumeStore

    U->>FO: Submit form data
    FO->>FO: Execute handleFormSubmit
    FO->>RS: Invoke setValues(payload)
    RS-->>FO: Update resume data
Loading
sequenceDiagram
    participant U as User
    participant PS as PictureSection
    participant PO as Popover

    U->>PS: Click to toggle popover
    PS->>PS: Execute handleOpen (toggle isOpen)
    PS->>PO: Update popover "open" state
    PO-->>PS: Render updated popover view
Loading

Poem

I'm a bunny coder, hopping in delight,
Form submissions and popovers making my day bright.
I nibble on each update with whiskers keen and spry,
Batch updates dance through my code under the sky.
With every toggle and input, my heart hops high! 🥕

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ 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.

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

🧹 Nitpick comments (1)
apps/client/src/pages/builder/sidebars/left/sections/picture/options.tsx (1)

33-33: Adjusted circle border radius from 9999 to 9998

The border radius for circle was changed from 9999 to 9998. While this works, it would be helpful to document why this specific value was chosen.

Consider adding a comment explaining the reason for using 9998 instead of 9999 or another round number.

Also applies to: 39-39

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd21860 and 5244a16.

📒 Files selected for processing (3)
  • apps/client/src/pages/builder/sidebars/left/sections/picture/options.tsx (5 hunks)
  • apps/client/src/pages/builder/sidebars/left/sections/picture/section.tsx (5 hunks)
  • apps/client/src/stores/resume.ts (2 hunks)
🔇 Additional comments (18)
apps/client/src/stores/resume.ts (2)

22-22: Implement batch state updates with the new setValues method

The new setValues method is a good addition that allows for efficiently updating multiple fields in one operation, reducing unnecessary re-renders.


44-52: Good implementation of batch update functionality

The implementation of setValues correctly handles the batch updates and properly triggers a debounced state update after applying all changes.

apps/client/src/pages/builder/sidebars/left/sections/picture/section.tsx (5)

15-15: Added useState import for popover state management

The import has been updated to include useState, which is correctly used to manage the popover state.


24-24: Added state management for popover visibility

The isOpen state variable is properly initialized and used to control the popover visibility.


51-53: Added handler to toggle popover visibility

The handleOpen function correctly toggles the isOpen state, providing a clean way to control the popover.


88-88: Popover component now uses controlled state

The Popover component is now properly controlled by the isOpen state variable.


100-100: PictureOptions now receives handleOpen prop

The PictureOptions component now correctly receives the handleOpen function as a prop, allowing it to close the popover after form submission.

apps/client/src/pages/builder/sidebars/left/sections/picture/options.tsx (11)

2-11: Updated imports to support form functionality

The imports have been properly updated to include the necessary components and types for form handling.


42-46: Added proper type definitions

The types have been properly defined to make the component more type-safe, including the new PictureOptionsProps type.


48-51: Updated component to accept handleOpen prop and use setValues

The component now correctly accepts the handleOpen prop and uses the setValues method from the ResumeStore.


63-71: Simplified event handlers for better readability

The event handlers have been simplified and now use more specific types, improving code clarity.


73-92: Added form submission handler with batch updates

The new handleFormSubmit function effectively processes form data and uses the setValues method to update multiple state values in a single operation. It also correctly calls handleOpen to close the popover after submission.


95-95: Wrapped component in form element with proper structure

The component is now properly wrapped in a form element with an onSubmit handler and a submit button.

However, the Button should explicitly have type="submit" to clarify its purpose.

-      <Button>{t`Save`}</Button>
+      <Button type="submit">{t`Save`}</Button>

Also applies to: 235-236


99-107: Updated Input props for size field

The Input component now uses defaultValue instead of value, which is appropriate for uncontrolled forms. The name attribute has been added to support form data collection.

However, consider using a more type-safe approach for the name attribute:

-          name={"size"}
+          name="size"

120-135: Added type="button" to ToggleGroupItems

The ToggleGroupItems now correctly have type="button" to prevent them from submitting the form when clicked. This is a good accessibility improvement.


139-148: Updated Input props for aspectRatio field

The Input component now uses defaultValue and includes a name attribute for form submission. The key attribute ensures the component re-renders when the value changes.

Similar to the size field, consider using a string literal instead of an object:

-          name={"aspectRatio"}
+          name="aspectRatio"

162-177: Added type="button" to border radius ToggleGroupItems

The ToggleGroupItems for border radius now have type="button", which is consistent with the aspect ratio toggle group items.


181-190: Updated Input props for borderRadius field

The Input component for border radius has been updated with similar improvements as the other fields.

Again, consider using a string literal for the name attribute:

-          name={"borderRadius"}
+          name="borderRadius"

@DemaPy
Copy link
Contributor Author

DemaPy commented Mar 16, 2025

Fix for this issue: #2234

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