fix inputs not blurring when pressing enter (#4692)

This commit is contained in:
Andreas Schmidt authored and GitHub committed 2022-01-19 08:27:55 -05:00
1 parent b7cb10521e
commit 86f14a9cdf
3 files changed
+25 -2

No files matched your search

+7
View File
@@ -52,6 +52,7 @@ export type InputProps = Omit<InputElementProps, "onChange" | "onSubmit"> & {
iconRight?: IconData;
contentRight?: string | React.ReactNode; // Any component of string goes after iconRight
validators?: InputValidator | InputValidator[];
blurOnEnter?: boolean;
onChange?(value: string, evt: React.ChangeEvent<InputElement>): void;
onSubmit?(value: string, evt: React.KeyboardEvent<InputElement>): void;
};
@@ -70,6 +71,7 @@ const defaultProps: Partial<InputProps> = {
maxRows: 10000,
showValidationLine: true,
validators: [],
blurOnEnter: true,
};
export class Input extends React.Component<InputProps, State> {
@@ -267,6 +269,11 @@ export class Input extends React.Component<InputProps, State> {
} else {
this.setDirty();
}
if(this.props.blurOnEnter){
//pressing enter indicates that the edit is complete, we can unfocus now
this.blur();
}
}
}