prevent EditableList input from blurring

Signed-off-by: ndrscodes <ndrscodes@gmail.com>
This commit is contained in:
Andreas Schmidt authored and ndrscodes committed 2022-01-14 17:05:19 +01:00
1 parent 1eef2bca2b
commit 0d134ed5cb
2 files changed
+8 -2

No files matched your search

@@ -56,6 +56,7 @@ export class EditableList<T> extends React.Component<Props<T>> {
if (val) {
evt.preventDefault();
this.props.add(val);
evt.stopPropagation();
}
}
@@ -70,6 +71,7 @@ export class EditableList<T> extends React.Component<Props<T>> {
onSubmit={this.onSubmit}
validators={validators}
placeholder={placeholder}
blurOnEnter={false}
iconRight={({ isDirty }) => isDirty ? <Icon material="keyboard_return" size={16} /> : null}
/>
</div>
+6 -2
View File
@@ -68,6 +68,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;
};
@@ -86,6 +87,7 @@ const defaultProps: Partial<InputProps> = {
maxRows: 10000,
showValidationLine: true,
validators: [],
blurOnEnter: true,
};
export class Input extends React.Component<InputProps, State> {
@@ -284,8 +286,10 @@ export class Input extends React.Component<InputProps, State> {
this.setDirty();
}
//pressing enter indicates that the edit is complete, we can unfocus now
this.blur();
if(this.props.blurOnEnter){
//pressing enter indicates that the edit is complete, we can unfocus now
this.blur();
}
}
}