Skip to content

Commit

Permalink
Fixed an issue with input of negative numbers
Browse files Browse the repository at this point in the history
Closes #1202
  • Loading branch information
valadas committed Oct 26, 2024
1 parent f0fc104 commit 977e253
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ export class DnnInput {
this.internals.setFormValue("");
}

private handleInput(value: string): void {
private handleInput(e: InputEvent): void {
if (this.type === "number" && e.data === "-") {
// Ignore the minus sign if the input type is number
return;
}
var value = (e.target as HTMLInputElement).value;
this.value = value;
var valid = this.inputField.checkValidity();
this.valid = valid;
Expand Down Expand Up @@ -229,7 +234,7 @@ export class DnnInput {
value={this.value}
onBlur={() => this.handleBlur()}
onFocus={() => this.focused = true}
onInput={e => this.handleInput((e.target as HTMLInputElement).value)}
onInput={e => this.handleInput(e)}
onInvalid={() => this.handleInvalid()}
onChange={() => this.handleChange()}
aria-labelledby={this.labelId}
Expand Down

0 comments on commit 977e253

Please sign in to comment.