fix: show error when Required is true and default selected value is e…
Fixes #15391 Showing error message similar to input widget.
Wrapped errortooltip around Dropdowncontainer. Added two props showError and errorMessage. Added jest unit tests since this is a functionality.
Summary by CodeRabbit
-
New Features
- Introduced error handling for the SelectWidget, displaying error messages when conditions are met.
- Added a new ErrorTooltip component for visual feedback on errors.
-
Bug Fixes
- Enhanced validation logic to ensure proper error handling for required fields and default selections.
-
Tests
- Implemented comprehensive unit tests for the SelectWidget to verify validation and error handling functionalities.
Walkthrough
The recent changes to the SelectWidget enhance its error handling and validation capabilities. By introducing an ErrorTooltip component and refining the validation logic, these updates ensure that users receive immediate feedback when required fields are not filled. This improvement not only enhances the user experience but also strengthens the overall functionality of the dropdown selection component.
Changes
| Files | Change Summary |
|---|---|
app/client/src/widgets/SelectWidget/component/index.tsx |
Integrated error handling via ErrorTooltip, updated props in the SelectComponentProps interface. |
app/client/src/widgets/SelectWidget/widget/index.tsx |
Enhanced validation logic, introduced isDefaultValueRequired, and improved error message handling. |
app/client/src/widgets/SelectWidget/widget/index.test.tsx |
Added comprehensive unit tests for validation logic and error handling related to required fields. |
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
| Ensure error is thrown if widget is required and no option is selected (#[15391]) | ✅ |
🎉 "Selects now shine with error signs,
Required values in clear view, no more whines.
Dropdowns with tooltips, guiding each choice,
A robust solution, let users rejoice!
With testing in place, reliability's key,
Here's to our widgets, as great as can be!" 🌟
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?
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
@coderabbitaiin 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
@coderabbitaiin 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 using PR comments)
-
@coderabbitai pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere 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.
hI @shadabbuchh @somangshu Could you please take this PR forward for review and add a reviewer?
Thanks in advance.
Hi @ramsaptami can you please add a reviewer and take this pr forward for review? Thanks in advance.
This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.
Hi @riodeuno @jsartisan can you please review pr?
@SaiCharanChetpelly31 Can you share a video on how the solution works? I couldn't see any tooltip when is required was true and there is no value. Also, the original issue talks about all the select widget family ( tree select, multi tree select, multiselect, and single select ), and the files you changed are only of select widget.
@SaiCharanChetpelly31 Can you share a video on how the solution works? I couldn't see any tooltop when is required was true and there is no value. Also, the original issue talks about all the select widget family ( tree select, multi tree select, multiselect, and single select ), and the files you changed are only of select widget.
Here is the video
https://github.com/user-attachments/assets/ac2ddd42-e011-4894-9b50-987f85d8387d
Forgot to fix for all select widgets, i will add it now.
@SaiCharanChetpelly31 The this.props.defaultOptionValue === "" is not needed IMO. If I am marking isRequired as true and I just unselected the selected options, shouldn't get the tooltip? With that check, we are not.
What you have done is, you are checking if the defaultOptionValue is also empty which is not right. The main idea was to show a tooltip if there is no selected value and the widget value is marked as required.
This is the exact reason I was not able to trigger the tooltip before
I couldn't see any tooltip when is required was true and there is no value.
Note that the above logic applies for all select family widgets.
@jsartisan Thanks for your reply. Understood. I will remove logic related to defaultValue in all select family widgets.
This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.
@jsartisan Please review this PR
@SaiCharanChetpelly31 Hey give me a day. I'll check this in the evening.
@SaiCharanChetpelly31 Really sorry for the delay. Got busy with tasks.
I tried the latest commit and it does not work properly. I saw the tooltip for one in edit mode but can't see it at all in deploy mode.
https://github.com/user-attachments/assets/4a10d8e2-7dc7-4ded-a157-4b635e9afcfe
I can see the red border but no tooltip.
The solution not working properly.
I will recheck and get back to ypu. Thanks for reviewing.