chore: Don't allow paste if input type is number and pasted text is not (#33845)
Fixes #33080 /ok-to-test tags="@tag.Anvil"<!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/9300922932> > Commit: fc768c03c81d4fe8371c2f708535c3a1194e6073 > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9300922932&attempt=1" target="_blank">Click here!</a> <!-- end of auto-generated comment: Cypress test results --> Co-authored-by: Pawan Kumar <pawankumar@Pawans-MacBook-Pro-2.local>
This commit is contained in:
parent
8eed4b589f
commit
ded2aeb8ce
|
|
@ -105,6 +105,7 @@ function InputComponent(props: InputComponentProps) {
|
||||||
onChange={props.onValueChange}
|
onChange={props.onValueChange}
|
||||||
onFocusChange={props.onFocusChange}
|
onFocusChange={props.onFocusChange}
|
||||||
onKeyDown={props.onKeyDown}
|
onKeyDown={props.onKeyDown}
|
||||||
|
onPaste={props.onPaste}
|
||||||
placeholder={props.placeholder}
|
placeholder={props.placeholder}
|
||||||
prefix={startIcon}
|
prefix={startIcon}
|
||||||
spellCheck={props.spellCheck}
|
spellCheck={props.spellCheck}
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,5 @@ export interface InputComponentProps extends BaseInputComponentProps {
|
||||||
autoComplete?: string;
|
autoComplete?: string;
|
||||||
iconAlign?: "left" | "right";
|
iconAlign?: "left" | "right";
|
||||||
iconName?: IconProps["name"];
|
iconName?: IconProps["name"];
|
||||||
|
onPaste?: (event: React.ClipboardEvent<HTMLInputElement>) => void;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -202,6 +202,16 @@ class WDSInputWidget extends WDSBaseInputWidget<InputWidgetProps, WidgetState> {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onPaste = (e: React.ClipboardEvent<HTMLInputElement>) => {
|
||||||
|
if (this.props.inputType === INPUT_TYPES.NUMBER) {
|
||||||
|
const pastedValue = e.clipboardData.getData("text");
|
||||||
|
|
||||||
|
if (isNaN(Number(pastedValue))) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
getWidgetView() {
|
getWidgetView() {
|
||||||
const { inputType, rawText } = this.props;
|
const { inputType, rawText } = this.props;
|
||||||
|
|
||||||
|
|
@ -227,6 +237,7 @@ class WDSInputWidget extends WDSBaseInputWidget<InputWidgetProps, WidgetState> {
|
||||||
minNum={this.props.minNum}
|
minNum={this.props.minNum}
|
||||||
onFocusChange={this.onFocusChange}
|
onFocusChange={this.onFocusChange}
|
||||||
onKeyDown={this.onKeyDown}
|
onKeyDown={this.onKeyDown}
|
||||||
|
onPaste={this.onPaste}
|
||||||
onValueChange={this.onValueChange}
|
onValueChange={this.onValueChange}
|
||||||
placeholder={this.props.placeholderText}
|
placeholder={this.props.placeholderText}
|
||||||
spellCheck={this.props.isSpellCheck}
|
spellCheck={this.props.isSpellCheck}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user