Skip to content

Conversation

jcfilben
Copy link
Collaborator

What does this PR do?

Fixes the typescript definition for onChange in FileInput

Where should the reviewer start?

What testing has been done on this PR?

Tested with the following code in a typescript story:

const onChange = (event, { files }) => {
  console.log(files);
);

and

const onChange = ({ target: { files } }) => {
  console.log(files);
};

with <FileInput onChange={onChange} />

How should this be manually tested?

Test an onChange function with FileInput in a typescript file

Do Jest tests follow these best practices?

  • screen is used for querying.
  • The correct query is used. (Refer to this list of queries)
  • userEvent is used in place of fireEvent.
  • asFragment() is used for snapshot testing.

Any background context you want to provide?

What are the relevant issues?

Closes #6143

Screenshots (if appropriate)

Do the grommet docs need to be updated?

No

Should this PR be mentioned in the release notes?

Maybe

Is this change backwards compatible or is it a breaking change?

Backwards compatible

@@ -22,10 +22,11 @@ export interface FileInputProps {
};
multiple?: boolean | { aggregateThreshold?: number; max?: number };
name?: string;
onChange?: (event?: any, { files }?: { files: any }) => void;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there anything more specific than any

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good comment, just updated this to make the types more specific

@jcfilben jcfilben requested a review from ericsoderberghp May 24, 2022 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't access { files } in the onChange method for FileInput in TypeScript
3 participants