mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
prevent EditableList input from blurring
Signed-off-by: ndrscodes <ndrscodes@gmail.com>
This commit is contained in:
parent
1eef2bca2b
commit
0d134ed5cb
@ -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>
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user