Skip to content

Conversation

riodeuno
Copy link
Contributor

@riodeuno riodeuno commented Jul 25, 2024

Description

Fixes #4653

Automation

/ok-to-test tags="@tag.All"

🔍 Cypress test results

Caution

🔴 🔴 🔴 Some tests have failed.
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/10112601666
Commit: 251e6b7
Cypress dashboard.
Tags: @tag.All
Spec:
The following are new failures, please fix them before merging the PR:

  1. cypress/e2e/Regression/ClientSide/IDE/Canvas_Context_Bug_Fixes.js
List of identified flaky tests.
Fri, 26 Jul 2024 15:01:45 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced input validation in the KeyValueComponent to provide error messages for empty fields.
    • Added visual feedback for input errors with conditional styling and an error icon.
    • Improved validation logic in the RadioGroupWidget to ensure that at least one field is filled.
  • Bug Fixes

    • Fixed error handling to accurately reflect input validation issues in both components.

@riodeuno riodeuno added the ok-to-test Required label for CI label Jul 25, 2024
@riodeuno riodeuno self-assigned this Jul 25, 2024
@github-actions github-actions bot added Widgets Product This label groups issues related to widgets Bug Something isn't working Low An issue that is neither critical nor breaks a user flow Low effort Takes 1-2 days Production Radio Widget labels Jul 25, 2024
Copy link
Contributor

coderabbitai bot commented Jul 25, 2024

Important

Review skipped

Auto reviews are limited to specific labels.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The recent changes enhance the user experience in the KeyValueComponent and RadioGroupWidget by implementing robust input validation mechanisms. These updates ensure that users receive immediate feedback about input errors, promoting better data integrity and usability. With new error handling visuals and validation logic, users can easily identify and correct issues with their input, thereby improving the overall interaction with these components.

Changes

File Path Change Summary
app/client/src/components/propertyControls/KeyValueComponent.tsx Added internal state for error messages, implemented validation for empty fields, and updated styling for error feedback.
app/client/src/widgets/RadioGroupWidget/widget/index.tsx Enhanced the optionsCustomValidation function to check for empty label and value fields, ensuring proper error messaging.

Assessment against linked issues

Objective Addressed Explanation
Ensure error message displays when label and value are empty (Issue #4653)
Improve user feedback for validation errors in the Radio button widget (Issue #4653)

Poem

In fields where inputs lie,
A warning icon catches the eye.
With every label, valid and neat,
Errors fade, making data complete!
So here’s to changes, a user’s delight,
Making our forms easy and bright! ✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@github-actions github-actions bot added skip-changelog Adding this label to a PR prevents it from being listed in the changelog Bug Something isn't working and removed Bug Something isn't working labels Jul 25, 2024
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: 2

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 18a4b50 and 9ffdc2b.

Files ignored due to path filters (1)
  • app/client/src/assets/icons/alert/warning-error.svg is excluded by !**/*.svg
Files selected for processing (2)
  • app/client/src/components/propertyControls/KeyValueComponent.tsx (9 hunks)
  • app/client/src/widgets/RadioGroupWidget/widget/index.tsx (1 hunks)
Additional comments not posted (12)
app/client/src/components/propertyControls/KeyValueComponent.tsx (11)

9-9: Good job adding the necessary import!

The import statement for WarningErrorIcon is correctly added and will be useful for displaying error icons in the validation logic.


42-46: Nice use of FlexBox for layout!

The FlexBox styled component is well-defined and will help in organizing the input fields and error messages.


48-57: Great job styling the error messages!

The ErrorMessageBox styled component is well-defined and will help in displaying error messages clearly.


63-81: Excellent use of conditional styling!

The StyledInputGroup styled component is well-defined and the conditional error styling is correctly implemented.


103-103: Good use of state to manage error messages!

The errorMessages state variable is correctly added and will help in tracking validation errors for each pair of input fields.


159-166: Great job on the validation logic!

The validatePairs function is well-implemented and correctly generates error messages for empty labels and values.


141-141: Good job integrating validation into updateKey!

The updateKey function now correctly calls validatePairs after updating the key, ensuring validation is performed.


156-157: Good job integrating validation into updateValue!

The updateValue function now correctly calls validatePairs after updating the value, ensuring validation is performed.


177-177: Good job integrating validation into deletePair!

The deletePair function now correctly calls validatePairs after deleting a pair, ensuring validation is performed.


211-211: Good job integrating validation into addPair!

The addPair function now correctly calls validatePairs after adding a new pair, ensuring validation is performed.


226-271: Excellent job on the error message display!

The render logic correctly displays error messages below each input field, providing clear feedback to the user.

app/client/src/widgets/RadioGroupWidget/widget/index.tsx (1)

73-81: Great job enhancing the validation logic!

The new validation condition in the optionsCustomValidation function correctly checks if both label and value are empty and sets the _isValid flag to false if true.

Comment on lines +159 to +166
function validatePairs(pairs: SegmentedControlOptionWithKey[]) {
const newErrorMessages = pairs.map((pair) => {
if (!pair.label && !pair.value) {
return "Both Name and Value can't be empty";
}
return "";
});
setErrorMessages(newErrorMessages);
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding unit tests for validation logic.

To ensure the robustness of the validatePairs function, consider adding unit tests to cover various scenarios.

Do you want me to help you write the unit tests for this function?

Comment on lines +73 to +81
if (!label && !value) {
_isValid = false;
message = {
name: "ValidationError",
message:
"Both Name and Value can't be empty",
};
break;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding unit tests for the new validation condition.

To ensure the robustness of the optionsCustomValidation function, consider adding unit tests to cover various scenarios, including the new validation condition.

Do you want me to help you write the unit tests for this function?

…o external-contri/fix/radio-button-widget-to-show-error-message-#4653
@riodeuno riodeuno removed the ok-to-test Required label for CI label Jul 26, 2024
@github-actions github-actions bot added the Bug Something isn't working label Jul 26, 2024
@riodeuno riodeuno added ok-to-test Required label for CI and removed Bug Something isn't working labels Jul 26, 2024
@github-actions github-actions bot added the Bug Something isn't working label Jul 26, 2024
@prasad-madine
Copy link
Contributor

Hello @riodeuno , Will look into this failed cypress spec and update the PR.

Copy link

github-actions bot commented Aug 5, 2024

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label Aug 5, 2024
Copy link

This PR has been closed because of inactivity.

@github-actions github-actions bot closed this Aug 12, 2024
@riodeuno riodeuno deleted the external-contri/fix/radio-button-widget-to-show-error-message-#4653 branch August 21, 2024 04:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working Low effort Takes 1-2 days Low An issue that is neither critical nor breaks a user flow ok-to-test Required label for CI Production Radio Widget skip-changelog Adding this label to a PR prevents it from being listed in the changelog Stale Widgets Product This label groups issues related to widgets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]In Radio button widget->In property pane->if the options section(label or value) is kept empty the required error message should be displayed

2 participants