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:
parent
36710e2b08
commit
c94684488d
@ -771,6 +771,7 @@ exports[`preferences - navigation to terminal preferences given in preferences,
|
|||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
class="input box grow"
|
class="input box grow"
|
||||||
|
max="50"
|
||||||
min="10"
|
min="10"
|
||||||
spellcheck="false"
|
spellcheck="false"
|
||||||
type="number"
|
type="number"
|
||||||
|
|||||||
@ -72,7 +72,7 @@ const NonInjectedTerminal = observer((
|
|||||||
<Input
|
<Input
|
||||||
theme="round-black"
|
theme="round-black"
|
||||||
placeholder={defaultShell}
|
placeholder={defaultShell}
|
||||||
value={userStore.shell}
|
value={userStore.shell ?? ""}
|
||||||
onChange={(value) => userStore.shell = value}
|
onChange={(value) => userStore.shell = value}
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@ -265,25 +265,24 @@ export class Input extends React.Component<InputProps, State> {
|
|||||||
setDirtyOnChange = debounce(() => this.setDirty(), 500);
|
setDirtyOnChange = debounce(() => this.setDirty(), 500);
|
||||||
|
|
||||||
async onChange(evt: React.ChangeEvent<any>) {
|
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 newValue = evt.currentTarget.value;
|
||||||
const eventCopy = { ...evt };
|
const eventCopy = { ...evt };
|
||||||
|
|
||||||
await this.validate(); // validate first
|
this.autoFitHeight();
|
||||||
|
this.setDirtyOnChange();
|
||||||
|
|
||||||
// don't propagate changes for invalid values
|
// Handle uncontrolled components (`props.defaultValue` must be used instead `value`)
|
||||||
// possible only with uncontrolled components (defaultValue={} must be used instead value={})
|
if (this.isUncontrolled) {
|
||||||
if (!this.isUncontrolled || (this.isUncontrolled && this.state.valid)) {
|
// update DOM since render() is not called on input's changes with uncontrolled inputs
|
||||||
this.props.onChange?.(newValue, eventCopy);
|
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>) {
|
onKeyDown(evt: React.KeyboardEvent<InputElement>) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user