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(island-ui): Only set SelectController placeholder for undefined or null values #16512

Merged
merged 4 commits into from
Oct 22, 2024

Conversation

helgifr
Copy link
Member

@helgifr helgifr commented Oct 22, 2024

We should only use the placeholder for undefined or null. Since this can affect falsy values and have unwanted results

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

    • Enhanced clarity in value validation for the SelectController component, ensuring better handling of null values.
    • Improved onChange functionality to clear errors before processing new selections.
  • Bug Fixes

    • Strengthened robustness of the component's value checks while maintaining existing multi-value selection functionality.

@helgifr helgifr requested review from a team as code owners October 22, 2024 14:38
@helgifr helgifr requested a review from Tryggvig October 22, 2024 14:38
Copy link
Contributor

coderabbitai bot commented Oct 22, 2024

Walkthrough

The changes in this pull request focus on the SelectController component within SelectController.tsx. The getValue function's condition for validating the value has been updated to explicitly check for null, enhancing clarity. Additionally, the onChange handler in the Select component now calls the clearErrors function with the id parameter before processing the new value. The functionality for handling multiple selections remains unchanged, ensuring that the component operates as intended.

Changes

File Path Change Summary
libs/shared/form-fields/src/lib/SelectController/... Updated getValue function to check for null instead of falsiness. Modified onChange handler to call clearErrors with id before processing new value. Maintained existing multi-value selection logic.

Possibly related PRs

  • fix: Show placeholder if select value is undefined #16462: This PR modifies the SelectController component in SelectController.tsx, specifically addressing how null values are handled, which is directly related to the changes made in the main PR regarding the getValue function's validation logic.

Suggested reviewers

  • jonnigs
  • ylfahfa
  • mannipje

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between bb9c07b and 8c19881.

📒 Files selected for processing (1)
  • libs/shared/form-fields/src/lib/SelectController/SelectController.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • libs/shared/form-fields/src/lib/SelectController/SelectController.tsx

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

🧹 Outside diff range and nitpick comments (1)
libs/shared/form-fields/src/lib/SelectController/SelectController.tsx (1)

Line range hint 1-124: Consider adding documentation and usage examples

The SelectController component adheres well to the coding guidelines for shared libraries. It's a reusable component with proper TypeScript usage. To further improve its usability across different NextJS apps, consider adding:

  1. JSDoc comments to describe the component's purpose and key features.
  2. Usage examples to demonstrate how to integrate this component in various scenarios.

This addition would align with the guideline: "Documentation and examples for library consumers."

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c77c769 and bb9c07b.

📒 Files selected for processing (1)
  • libs/shared/form-fields/src/lib/SelectController/SelectController.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/shared/form-fields/src/lib/SelectController/SelectController.tsx (2)

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

  • Cross-application utility functions, types, and constants.
  • TypeScript best practices to ensure type safety and reusability.
  • Documentation and examples for library consumers."

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 (1)
libs/shared/form-fields/src/lib/SelectController/SelectController.tsx (1)

60-61: Improved type safety and clarity in value checking

The change from if (!value) to if (value === undefined || value === null) enhances type safety and clarity. This explicit check aligns well with TypeScript best practices and makes the code more robust by specifically handling undefined and null cases.

Copy link

codecov bot commented Oct 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.76%. Comparing base (368b5fc) to head (8c19881).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #16512   +/-   ##
=======================================
  Coverage   36.76%   36.76%           
=======================================
  Files        6847     6847           
  Lines      141884   141884           
  Branches    40429    40429           
=======================================
  Hits        52167    52167           
  Misses      89717    89717           
Flag Coverage Δ
api 3.37% <ø> (ø)
application-api-files 56.86% <ø> (ø)
application-system-api 41.34% <ø> (ø)
application-template-api-modules 27.79% <ø> (-0.01%) ⬇️
application-templates-accident-notification 29.27% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-driving-license 18.34% <ø> (ø)
application-templates-estate 12.32% <0.00%> (ø)
application-templates-financial-aid 15.50% <ø> (ø)
application-templates-general-petition 23.44% <ø> (ø)
application-templates-inheritance-report 6.49% <ø> (ø)
application-templates-marriage-conditions 15.17% <ø> (ø)
application-templates-mortgage-certificate 43.82% <ø> (ø)
application-templates-parental-leave 29.96% <ø> (ø)
application-ui-components 1.28% <ø> (ø)
application-ui-shell 21.36% <0.00%> (ø)
shared-form-fields 31.60% <100.00%> (ø)
web 1.81% <ø> (ø)

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

Files with missing lines Coverage Δ
...elds/src/lib/SelectController/SelectController.tsx 55.17% <100.00%> (ø)

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 368b5fc...8c19881. Read the comment docs.

@ylfahfa ylfahfa added the automerge Merge this PR as soon as all checks pass label Oct 22, 2024
@datadog-island-is
Copy link

datadog-island-is bot commented Oct 22, 2024

Datadog Report

All test runs 1f93e28 🔗

16 Total Test Services: 0 Failed, 15 Passed
➡️ Test Sessions change in coverage: 76 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 3.18s 1 no change Link
application-api-files 0 0 0 12 0 6.83s 1 no change Link
application-system-api 0 0 0 120 2 4m 0.59s 1 no change Link
application-template-api-modules 0 0 0 123 0 2m 45.02s 1 no change Link
application-templates-accident-notification 0 0 0 148 0 23.38s 1 no change Link
application-templates-driving-license 0 0 0 13 0 15.7s 1 no change Link
application-templates-financial-aid 0 0 0 11 0 14.8s 1 no change Link
application-templates-general-petition 0 0 0 5 0 11.37s 1 no change Link
application-templates-health-insurance 0 0 0 0 0 529.18ms 1 no change Link
application-templates-mortgage-certificate 0 0 0 3 0 20.31s 1 no change Link

@RunarVestmann RunarVestmann changed the title Fix: Only set placeholder for undefined or null fix(island-ui): Only set SelectController placeholder for undefined or null Oct 22, 2024
@RunarVestmann RunarVestmann changed the title fix(island-ui): Only set SelectController placeholder for undefined or null fix(island-ui): Only set SelectController placeholder for undefined or null values Oct 22, 2024
@kodiakhq kodiakhq bot merged commit cf03b8c into main Oct 22, 2024
79 checks passed
@kodiakhq kodiakhq bot deleted the fix/select-placeholder-only-undefined-or-null branch October 22, 2024 15:56
ylfahfa pushed a commit that referenced this pull request Oct 22, 2024
…r null values (#16512)

* Fix: Only set placeholder for undefined or null

* conditional only for null

---------

Co-authored-by: hfhelgason <hfhelgason@deloitte.is>
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.

4 participants