Skip to content

Commit

Permalink
fix(input): update files property on input event when type="file" (#1…
Browse files Browse the repository at this point in the history
…1262)

**Related Issue:** #9581

## Summary

Ensure the `files` property is updated before `calciteInputInput` is
emitted for `type="file"` inputs.
  • Loading branch information
benelan authored Jan 11, 2025
1 parent b69219f commit eddf102
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/calcite-components/src/components/input/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -669,16 +669,15 @@ export class Input
this.calciteInternalInputFocus.emit();
}

private inputChangeHandler(): void {
if (this.type === "file") {
this.files = (this.childEl as HTMLInputElement).files;
}
}

private inputInputHandler(nativeEvent: InputEvent): void {
if (this.disabled || this.readOnly) {
return;
}

if (this.type === "file") {
this.files = (this.childEl as HTMLInputElement).files;
}

this.setValue({
nativeEvent,
origin: "user",
Expand Down Expand Up @@ -1121,7 +1120,6 @@ export class Input
multiple={this.multiple}
name={this.name}
onBlur={this.inputBlurHandler}
onChange={this.inputChangeHandler}
onFocus={this.inputFocusHandler}
onInput={this.inputInputHandler}
onKeyDown={this.inputKeyDownHandler}
Expand Down

0 comments on commit eddf102

Please sign in to comment.