Skip to content

chore: fix validation in wds phoneinput widget#34177

Merged
jsartisan merged 1 commit intoreleasefrom
fix/phone-input-validation
Jun 12, 2024
Merged

chore: fix validation in wds phoneinput widget#34177
jsartisan merged 1 commit intoreleasefrom
fix/phone-input-validation

Conversation

@jsartisan
Copy link
Contributor

@jsartisan jsartisan commented Jun 11, 2024

Fixes #34057

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

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9478894908
Commit: 3763570
Cypress dashboard url: Click here!

Summary by CodeRabbit

  • Bug Fixes
    • Improved phone input validation by using parsed text for more accurate results.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 11, 2024

Walkthrough

The validateInput function in the WDSPhoneInputWidget module has been updated to use props.parsedText instead of props.text for the value variable assignment. This change aims to fix the incorrect validation issue when the required field is turned on in the phone widget.

Changes

File Path Change Summary
app/client/src/widgets/wds/WDSPhoneInputWidget/widget/helpers.ts Updated validateInput function to use props.parsedText instead of props.text for validation.

Assessment against linked issues

Objective (Issue #) Addressed Explanation
Fix incorrect validation on the phone widget when required field is turned on (#34057)

Poem

In the code where widgets play,
A phone's validation went astray.
With parsedText now in its rightful place,
The phone widget keeps a steady pace.
Bugs are gone, the code's delight,
Phone inputs now are always right! 🌟📞


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 Configration 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 Anvil Pod Issue related to Anvil project Bug Something isn't working Deploy Preview Issues found in Deploy Preview High This issue blocks a user from building or impacts a lot of users Regressed Scenarios that were working before but have now regressed WDS team labels Jun 11, 2024
@jsartisan jsartisan added the ok-to-test Required label for CI label Jun 11, 2024
@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 Jun 11, 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: 1

Outside diff range and nitpick comments (1)
app/client/src/widgets/wds/WDSPhoneInputWidget/widget/helpers.ts (1)

Line range hint 45-47: Remove the unnecessary else clause to simplify the code.

-  if (option) {
-    return option.code;
-  } else {
-    return "";
-  }
+  return option ? option.code : "";
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e6ebd41 and 8f37edaa0263bbe36c0deb777a2710e3dbd3af32.

Files selected for processing (1)
  • app/client/src/widgets/wds/WDSPhoneInputWidget/widget/helpers.ts (1 hunks)
Additional context used
Biome
app/client/src/widgets/wds/WDSPhoneInputWidget/widget/helpers.ts

[error] 45-47: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.

Additional comments not posted (1)
app/client/src/widgets/wds/WDSPhoneInputWidget/widget/helpers.ts (1)

Line range hint 15-23: This function looks good and uses modern JavaScript features effectively.

Copy link
Contributor

Choose a reason for hiding this comment

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

Correct the typo in the return object's property name.

- validattionStatus: isInvalid ? "invalid" : undefined,
+ validationStatus: isInvalid ? "invalid" : undefined,
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const value = props.parsedText ?? "";
const value = props.parsedText ?? "";
// Other code in the function
return {
validationStatus: isInvalid ? "invalid" : undefined,
// Other properties in the return object
};

@jsartisan jsartisan requested a review from KelvinOm June 12, 2024 06:34
@jsartisan jsartisan force-pushed the fix/phone-input-validation branch from 8f37eda to 3763570 Compare June 12, 2024 07:35
@github-actions github-actions bot added Bug Something isn't working and removed Bug Something isn't working labels Jun 12, 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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8f37edaa0263bbe36c0deb777a2710e3dbd3af32 and 3763570.

Files selected for processing (1)
  • app/client/src/widgets/wds/WDSPhoneInputWidget/widget/helpers.ts (1 hunks)
Additional context used
Biome
app/client/src/widgets/wds/WDSPhoneInputWidget/widget/helpers.ts

[error] 45-47: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.

Additional comments not posted (5)
app/client/src/widgets/wds/WDSPhoneInputWidget/widget/helpers.ts (5)

9-9: Change to use props.parsedText seems appropriate for addressing the validation issue.


Line range hint 24-24: Function countryToFlag correctly converts dial codes to flags using Unicode code points.


Line range hint 45-47: Remove the unnecessary else clause to simplify the code.
[REFACTOR_SUGGESTion]

-  } else {
-    return "";
-  }
+  }
+  return "";

9-9: Correct the typo in the return object's property name.

- validattionStatus: isInvalid ? "invalid" : undefined,
+ validationStatus: isInvalid ? "invalid" : undefined,

Likely invalid or redundant comment.


9-9: Ensure that props.parsedText is always defined or handled appropriately in all use cases.

Verification successful

The search results indicate that props.parsedText is handled appropriately in various instances across the codebase, often using nullish coalescing (??) or logical OR (||) operators to provide default values.

  • app/client/src/widgets/wds/WDSPhoneInputWidget/widget/index.tsx
  • app/client/src/widgets/wds/WDSPhoneInputWidget/widget/helpers.ts
  • app/client/src/widgets/wds/WDSInputWidget/widget/index.tsx
  • app/client/src/widgets/wds/WDSCurrencyInputWidget/widget/index.tsx
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `props.parsedText` is always defined or handled appropriately.

# Test: Search for the property usage. Expect: Proper handling in all occurrences.
rg --type typescript $'props.parsedText'

Length of output: 74



Script:

#!/bin/bash
# Description: Verify that `props.parsedText` is always defined or handled appropriately.

# Test: Search for the property usage. Expect: Proper handling in all occurrences.
rg --type ts 'props.parsedText'

Length of output: 2059

@jsartisan jsartisan added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jun 12, 2024
@github-actions github-actions bot added the Bug Something isn't working label Jun 12, 2024
@jsartisan jsartisan merged commit 6e5f306 into release Jun 12, 2024
@jsartisan jsartisan deleted the fix/phone-input-validation branch June 12, 2024 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Anvil Pod Issue related to Anvil project Bug Something isn't working Deploy Preview Issues found in Deploy Preview High This issue blocks a user from building or impacts a lot of users ok-to-test Required label for CI Regressed Scenarios that were working before but have now regressed skip-changelog Adding this label to a PR prevents it from being listed in the changelog WDS team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Incorrect validation on the phone widget when required field is turned on

2 participants