1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

update snapshots, fix tests

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2022-06-06 12:31:47 +03:00
parent 36710e2b08
commit c94684488d
3 changed files with 15 additions and 15 deletions

View File

@ -771,6 +771,7 @@ exports[`preferences - navigation to terminal preferences given in preferences,
>
<input
class="input box grow"
max="50"
min="10"
spellcheck="false"
type="number"

View File

@ -72,7 +72,7 @@ const NonInjectedTerminal = observer((
<Input
theme="round-black"
placeholder={defaultShell}
value={userStore.shell}
value={userStore.shell ?? ""}
onChange={(value) => userStore.shell = value}
/>
</section>

View File

@ -265,25 +265,24 @@ export class Input extends React.Component<InputProps, State> {
setDirtyOnChange = debounce(() => this.setDirty(), 500);
async onChange(evt: React.ChangeEvent<any>) {
this.autoFitHeight();
this.setDirtyOnChange();
// re-render component when used as uncontrolled input
// when used @defaultValue instead of @value changing real input.value doesn't call render()
if (this.isUncontrolled && this.showMaxLenIndicator) {
this.forceUpdate();
}
const newValue = evt.currentTarget.value;
const eventCopy = { ...evt };
await this.validate(); // validate first
this.autoFitHeight();
this.setDirtyOnChange();
// don't propagate changes for invalid values
// possible only with uncontrolled components (defaultValue={} must be used instead value={})
if (!this.isUncontrolled || (this.isUncontrolled && this.state.valid)) {
this.props.onChange?.(newValue, eventCopy);
// Handle uncontrolled components (`props.defaultValue` must be used instead `value`)
if (this.isUncontrolled) {
// update DOM since render() is not called on input's changes with uncontrolled inputs
if (this.showMaxLenIndicator) this.forceUpdate();
// don't propagate changes for invalid values
await this.validate();
if (!this.state.valid) return; // skip
}
// emit new value update
this.props.onChange?.(newValue, eventCopy);
}
onKeyDown(evt: React.KeyboardEvent<InputElement>) {