Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(react): adjust validation logic for files uploaded #11361

Merged
merged 5 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/react/src/components/FileUploader/FileUploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ export default class FileUploader extends React.Component {
accept: PropTypes.arrayOf(PropTypes.string),

/**
* Specify the type of the <FileUploaderButton>
* Specify the type of the `<FileUploaderButton>`
*/
buttonKind: PropTypes.oneOf(ButtonKinds),

/**
* Provide the label text to be read by screen readers when interacting with
* the <FileUploaderButton>
* the `<FileUploaderButton>`
*/
buttonLabel: PropTypes.string,

Expand Down Expand Up @@ -62,7 +62,7 @@ export default class FileUploader extends React.Component {
labelDescription: PropTypes.string,

/**
* Specify the title text of this <FileUploader>
* Specify the title text of this `<FileUploader>`
*/
labelTitle: PropTypes.string,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ FileUploaderButton.propTypes = {
multiple: PropTypes.bool,

/**
* Provide a name for the underlying <input> node
* Provide a name for the underlying `<input>` node
*/
name: PropTypes.string,

/**
* Provide an optional `onChange` hook that is called each time the <input>
* Provide an optional `onChange` hook that is called each time the `<input>`
* value changes
*/
onChange: PropTypes.func,
Expand All @@ -165,7 +165,7 @@ FileUploaderButton.propTypes = {
onClick: PropTypes.func,

/**
* Provide an accessibility role for the <FileUploaderButton>
* Provide an accessibility role for the `<FileUploaderButton>`
*/
role: PropTypes.string,

Expand All @@ -178,7 +178,7 @@ FileUploaderButton.propTypes = {
: PropTypes.oneOf(['default', 'field', 'small', 'sm', 'md', 'lg']),

/**
* Provide a custom tabIndex value for the <FileUploaderButton>
* Provide a custom tabIndex value for the `<FileUploaderButton>`
*/
tabIndex: PropTypes.number,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,14 @@ function FileUploaderDropContainer({
return acc;
}
const [fileExtension] = name.match(fileExtensionRegExp);
if (acceptedTypes.has(mimeType) || acceptedTypes.has(fileExtension)) {

if (
acceptedTypes.has(mimeType) ||
acceptedTypes.has(fileExtension.toLowerCase())
) {
return acc.concat([curr]);
}

curr.invalidFileType = true;
return acc.concat([curr]);
}, []);
Expand Down Expand Up @@ -185,12 +190,12 @@ FileUploaderDropContainer.propTypes = {
pattern: PropTypes.string,

/**
* Provide an accessibility role for the <FileUploaderButton>
* Provide an accessibility role for the `<FileUploaderButton>`
*/
role: PropTypes.string,

/**
* Provide a custom tabIndex value for the <FileUploaderButton>
* Provide a custom tabIndex value for the `<FileUploaderButton>`
*/
tabIndex: PropTypes.number,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@

import React, { useState, useCallback, useEffect } from 'react';
import classnames from 'classnames';
import {
FileUploaderItem,
FileUploaderDropContainer,
FormItem,
} from 'carbon-components-react';
import FileUploaderItem from '../../FileUploaderItem';
import FileUploaderDropContainer from '../../FileUploaderDropContainer';
import FormItem from '../../../FormItem';

// import uid from '../../../tools/uniqueId';
import '../FileUploader-story.scss';

Expand Down