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(application-system): Fix checkbox half width and third width layout #17305

Merged
merged 2 commits into from
Dec 20, 2024

Conversation

norda-gunni
Copy link
Member

@norda-gunni norda-gunni commented Dec 20, 2024

...

Attach a link to issue if relevant

What

Specify what you're trying to achieve

Why

Specify why you need to achieve this

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Updated the width of the fields in the repeater section to occupy full width.
  • Refactor

    • Introduced a helper function to determine the span of components, improving code clarity and maintainability.
    • Streamlined conditional logic for rendering component widths.

@norda-gunni norda-gunni requested a review from a team as a code owner December 20, 2024 09:01
Copy link
Contributor

coderabbitai bot commented Dec 20, 2024

Walkthrough

The pull request introduces modifications to the fieldsRepeaterSubsection configuration and related UI components. The primary change is updating the width property of the fieldsRepeater field from 'half' to 'full', affecting the layout of fields within the repeater. Additionally, new helper functions like getSpan are introduced in FieldsRepeaterItem.tsx and TableRepeaterItem.tsx to streamline span calculation logic, improving code readability and maintainability.

Changes

File Change Summary
libs/application/templates/reference-template/src/forms/exampleForm/tablesAndRepeatersSection/fieldsRepeaterSubsection.ts Updated fieldsRepeater width from 'half' to 'full'
libs/application/ui-fields/src/lib/FieldsRepeaterFormField/FieldsRepeaterItem.tsx Introduced getSpan helper function, simplified span calculation logic
libs/application/ui-fields/src/lib/TableRepeaterFormField/TableRepeaterItem.tsx Added getSpan helper function, refined component span determination

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • HjorturJ
  • Toti91

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

Copy link

codecov bot commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 0% with 20 lines in your changes missing coverage. Please review.

Project coverage is 35.68%. Comparing base (9364323) to head (4b9bc86).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...lib/FieldsRepeaterFormField/FieldsRepeaterItem.tsx 0.00% 10 Missing ⚠️
...c/lib/TableRepeaterFormField/TableRepeaterItem.tsx 0.00% 10 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17305      +/-   ##
==========================================
- Coverage   35.69%   35.68%   -0.01%     
==========================================
  Files        6928     6921       -7     
  Lines      148718   148521     -197     
  Branches    42495    42405      -90     
==========================================
- Hits        53087    53006      -81     
+ Misses      95631    95515     -116     
Flag Coverage Δ
api 3.33% <ø> (ø)
application-system-api 38.74% <ø> (-0.01%) ⬇️
application-template-api-modules 27.69% <ø> (+<0.01%) ⬆️
application-templates-parental-leave 29.93% <ø> (ø)
application-ui-shell 22.28% <0.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...lib/FieldsRepeaterFormField/FieldsRepeaterItem.tsx 1.98% <0.00%> (-0.13%) ⬇️
...c/lib/TableRepeaterFormField/TableRepeaterItem.tsx 2.02% <0.00%> (-0.14%) ⬇️

... and 39 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9364323...4b9bc86. Read the comment docs.

@datadog-island-is
Copy link

Datadog Report

All test runs c3fed40 🔗

5 Total Test Services: 0 Failed, 5 Passed
🔻 Test Sessions change in coverage: 2 decreased, 29 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 2.98s 1 no change Link
application-system-api 0 0 0 46 0 2m 21.33s 1 no change Link
application-template-api-modules 0 0 0 118 0 2m 21.58s 1 decreased (-0.01%) Link
application-templates-parental-leave 0 0 0 163 0 17.5s 1 no change Link
application-ui-shell 0 0 0 74 0 33.28s 1 decreased (-0.06%) Link

🔻 Code Coverage Decreases vs Default Branch (2)

  • application-ui-shell - jest 29.11% (-0.06%) - Details
  • application-template-api-modules - jest 30.08% (-0.01%) - Details

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

🧹 Nitpick comments (1)
libs/application/ui-fields/src/lib/FieldsRepeaterFormField/FieldsRepeaterItem.tsx (1)

49-60: Consider moving getSpan to a shared utility

The getSpan function is duplicated in both FieldsRepeaterItem and TableRepeaterItem. Consider extracting it to a shared utility to maintain DRY principles and ensure consistent behavior.

+ // New file: libs/application/ui-fields/src/lib/utils/layout.ts
+ export const getSpan = (component: string, width: string) => {
+   if (component !== 'radio' && component !== 'checkbox') {
+     if (width === 'half') {
+       return '1/2'
+     }
+     if (width === 'third') {
+       return '1/3'
+     }
+     return '1/1'
+   }
+   return '1/1'
+ }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b76b7dd and eb1cde3.

📒 Files selected for processing (3)
  • libs/application/templates/reference-template/src/forms/exampleForm/tablesAndRepeatersSection/fieldsRepeaterSubsection.ts (1 hunks)
  • libs/application/ui-fields/src/lib/FieldsRepeaterFormField/FieldsRepeaterItem.tsx (3 hunks)
  • libs/application/ui-fields/src/lib/TableRepeaterFormField/TableRepeaterItem.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
libs/application/ui-fields/src/lib/TableRepeaterFormField/TableRepeaterItem.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/reference-template/src/forms/exampleForm/tablesAndRepeatersSection/fieldsRepeaterSubsection.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/ui-fields/src/lib/FieldsRepeaterFormField/FieldsRepeaterItem.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🔇 Additional comments (3)
libs/application/templates/reference-template/src/forms/exampleForm/tablesAndRepeatersSection/fieldsRepeaterSubsection.ts (1)

26-26: Verify layout impact of full-width repeater

The change from 'half' to 'full' width will make the fields repeater span the entire container width. While this aligns with the PR objective, please ensure this doesn't negatively impact the layout of nested fields, especially those with 'half' and 'third' widths.

✅ Verification successful

Let me gather more context about the field builder implementation to understand the width handling.


Let me check the FieldsRepeaterFormField implementation to understand how the width property is handled.


Let me check the styling implementation and Box component usage in the FieldsRepeaterFormField component.


Based on the code analysis, I can now provide a final response:

Width change from 'half' to 'full' is safe and consistent with the component's design

The change from 'half' to 'full' width for the fields repeater is safe because:

  1. The FieldsRepeaterFormField component properly handles width through Box components
  2. The width property is used for layout purposes only and doesn't affect functionality
  3. Child fields maintain their own width properties independently (as seen in the stories where email field has width: 'half')
  4. The core implementation in libs/application/core/src/lib/fieldBuilders.ts also uses 'full' width as default
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other fieldsRepeater configurations to ensure consistency
rg -l "buildFieldsRepeaterField" | xargs rg "width: ['\"](half|full)['\"]"

Length of output: 1168


Script:

#!/bin/bash
# Check the implementation of buildFieldsRepeaterField to understand width handling
ast-grep --pattern 'buildFieldsRepeaterField = function($$$) {
  $$$
}'

# Also check for any width-related components or interfaces
rg -A 5 'interface.*Field.*Props' 

Length of output: 63127


Script:

#!/bin/bash
# Check the FieldsRepeaterFormField implementation
rg -A 10 "FieldsRepeaterFormField = " libs/application/ui-fields/src/lib/FieldsRepeaterFormField/FieldsRepeaterFormField.tsx

# Also check for any width-related styling
rg "width: .*props\.field\.width" libs/application/ui-fields/src/lib/FieldsRepeaterFormField/

Length of output: 411


Script:

#!/bin/bash
# Check the entire FieldsRepeaterFormField component file for Box/width usage
cat libs/application/ui-fields/src/lib/FieldsRepeaterFormField/FieldsRepeaterFormField.tsx

# Also check for any width-related styling in the stories
cat libs/application/ui-fields/src/lib/FieldsRepeaterFormField/FieldsRepeaterFormField.stories.mdx

Length of output: 9092

libs/application/ui-fields/src/lib/FieldsRepeaterFormField/FieldsRepeaterItem.tsx (1)

218-218: LGTM: Improved readability of split calculation

The ternary operator makes the split calculation more concise and readable.

libs/application/ui-fields/src/lib/TableRepeaterFormField/TableRepeaterItem.tsx (1)

49-60: Duplicate implementation detected

This implementation is identical to FieldsRepeaterItem.tsx. As mentioned in the previous review comment, these shared functions should be moved to a common utility file to avoid duplication and maintain consistency.

Also applies to: 218-218

Copy link
Member

@jonnigs jonnigs left a comment

Choose a reason for hiding this comment

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

LGTM

@norda-gunni norda-gunni added the automerge Merge this PR as soon as all checks pass label Dec 20, 2024
@norda-gunni norda-gunni changed the title fix(application-system): Fix checkbox width and third width layout fix(application-system): Fix checkbox half width and third width layout Dec 20, 2024
@kodiakhq kodiakhq bot merged commit 0d1d63e into main Dec 20, 2024
52 checks passed
@kodiakhq kodiakhq bot deleted the as-fix-widths-in-repeaters branch December 20, 2024 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants