Skip to content

Commit

Permalink
Merge branch 'fix/Issue_25911_onTextChanged_phone_input_widget' of ht…
Browse files Browse the repository at this point in the history
…tps://github.com/SaiCharanChetpelly31/appsmith into fix/Issue_25911_onTextChanged_phone_input_widget
  • Loading branch information
SaiCharanChetpelly31 committed Sep 27, 2024
2 parents c2fcd51 + beea37b commit 6eb0a71
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ describe(

agHelper.ClearNType(locators._input, "100");
agHelper.ValidateToastMessage("Value Changed");
agHelper.WaitUntilToastDisappear("Value Changed");
agHelper.ClearNType(locators._input, "a");
cy.get(locators._toastMsg).should("not.exist");

// onFocus
propPane.SelectPlatformFunction("onFocus", "Show alert");
Expand Down
12 changes: 12 additions & 0 deletions app/client/src/widgets/PhoneInputWidget/widget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,18 @@ class PhoneInputWidget extends BaseInputWidget<
},
});

// This regular expression validates that the input:
// - Does not start with a whitespace character
// - Contains only digits, spaces, parentheses, plus, and minus symbols
if (/^(?!\s)[\d\s()+-]*$/.test(value)) {
this.props.updateWidgetMetaProperty("text", formattedValue, {
triggerPropertyName: "onTextChanged",
dynamicString: this.props.onTextChanged,
event: {
type: EventType.ON_TEXT_CHANGE,
},
});
}
if (!this.props.isDirty) {
this.props.updateWidgetMetaProperty("isDirty", true);
}
Expand Down

0 comments on commit 6eb0a71

Please sign in to comment.