Skip to content

Commit 5f638fd

Browse files
fixup! fixup! Allow to reset FileInputField internal state by calling resetState function on its ref (#630)
1 parent 2c5d01d commit 5f638fd

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/components/FileInputField/FileInputField.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,14 @@ export const FileInputField = React.forwardRef((props, ref) => {
5252
}, [onFilesChanged]);
5353

5454
// We need to have a reference to the input element to be able to call its methods,
55-
// but at the same time we want to expose this reference to the parent component for
55+
// but at the same time we want to expose this reference to the parent component in
5656
// case someone wants to call input methods from outside the component.
5757
useImperativeHandle(
5858
ref,
5959
() => {
60+
// The reason of extending object instead of using spread operator is that
61+
// if it is transformed to the object, it changes the reference of the object
62+
// and its prototype chain.
6063
const inputEl = internalInputRef?.current ?? {};
6164
inputEl.resetState = () => {
6265
handleReset(null);

src/components/FileInputField/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ React.createElement(() => {
272272
```
273273

274274
You can also reset the input state by clicking the button with the `reset` type
275-
inside the form.
275+
inside a form.
276276

277277
## Forwarding HTML Attributes
278278

0 commit comments

Comments
 (0)