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

Transform the accept prop into a string everywhere #5380

Merged
merged 3 commits into from
Aug 1, 2024

Conversation

lakesare
Copy link
Contributor

@lakesare lakesare commented Aug 1, 2024

This PR passes a string to accept, just like its type wants (property) JSXInternal.HTMLAttributes<HTMLInputElement>.accept?: string | undefined.

Technically, accept was already transforming the array into a string - but that was undocumented behaviour.

Before

image

After

image

@lakesare lakesare marked this pull request as draft August 1, 2024 09:31
@lakesare lakesare changed the title /dev/Dashboard.js - add all restrictions for the development environment Transform the accept prop into a string everywhere Aug 1, 2024
@lakesare lakesare marked this pull request as ready for review August 1, 2024 09:50
Copy link
Contributor

github-actions bot commented Aug 1, 2024

Diff output files
diff --git a/packages/@uppy/dashboard/lib/components/AddFiles.js b/packages/@uppy/dashboard/lib/components/AddFiles.js
index 07770cb..8a0edf9 100644
--- a/packages/@uppy/dashboard/lib/components/AddFiles.js
+++ b/packages/@uppy/dashboard/lib/components/AddFiles.js
@@ -19,6 +19,7 @@ class AddFiles extends Component {
       event.target.value = null;
     };
     this.renderHiddenInput = (isFolder, refCallback) => {
+      var _this$props$allowedFi;
       return h("input", {
         className: "uppy-Dashboard-input",
         hidden: true,
@@ -29,7 +30,9 @@ class AddFiles extends Component {
         name: "files[]",
         multiple: this.props.maxNumberOfFiles !== 1,
         onChange: this.onFileInputChange,
-        accept: this.props.allowedFileTypes,
+        accept: (_this$props$allowedFi = this.props.allowedFileTypes) == null
+          ? void 0
+          : _this$props$allowedFi.join(", "),
         ref: refCallback,
       });
     };
diff --git a/packages/@uppy/drag-drop/lib/DragDrop.js b/packages/@uppy/drag-drop/lib/DragDrop.js
index bf02d06..5f2d2c3 100644
--- a/packages/@uppy/drag-drop/lib/DragDrop.js
+++ b/packages/@uppy/drag-drop/lib/DragDrop.js
@@ -101,6 +101,7 @@ export default class DragDrop extends UIPlugin {
     this.i18nInit();
   }
   renderHiddenFileInput() {
+    var _restrictions$allowed;
     const {
       restrictions,
     } = this.uppy.opts;
@@ -113,7 +114,9 @@ export default class DragDrop extends UIPlugin {
       },
       name: this.opts.inputName,
       multiple: restrictions.maxNumberOfFiles !== 1,
-      accept: restrictions.allowedFileTypes,
+      accept: (_restrictions$allowed = restrictions.allowedFileTypes) == null
+        ? void 0
+        : _restrictions$allowed.join(", "),
       onChange: this.onInputChange,
     });
   }
diff --git a/packages/@uppy/file-input/lib/FileInput.js b/packages/@uppy/file-input/lib/FileInput.js
index 90b6833..13cfa50 100644
--- a/packages/@uppy/file-input/lib/FileInput.js
+++ b/packages/@uppy/file-input/lib/FileInput.js
@@ -48,6 +48,7 @@ export default class FileInput extends UIPlugin {
     this.input.click();
   }
   render() {
+    var _restrictions$allowed;
     const hiddenInputStyle = {
       width: "0.1px",
       height: "0.1px",
@@ -59,7 +60,6 @@ export default class FileInput extends UIPlugin {
     const {
       restrictions,
     } = this.uppy.opts;
-    const accept = restrictions.allowedFileTypes ? restrictions.allowedFileTypes.join(",") : undefined;
     return h(
       "div",
       {
@@ -72,7 +72,9 @@ export default class FileInput extends UIPlugin {
         name: this.opts.inputName,
         onChange: this.handleInputChange,
         multiple: restrictions.maxNumberOfFiles !== 1,
-        accept: accept,
+        accept: (_restrictions$allowed = restrictions.allowedFileTypes) == null
+          ? void 0
+          : _restrictions$allowed.join(", "),
         ref: input => {
           this.input = input;
         },

// minNumberOfFiles: 1,
// allowedFileTypes: ['image/*', '.jpg', '.jpeg', '.png', '.gif'],
// requiredMetaFields: ['caption'],
// }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This adds all existing restrictions to our dev file - I frequently need those, and I assume others do too

@lakesare lakesare requested a review from aduh95 August 1, 2024 09:55
@lakesare lakesare merged commit b9582e1 into main Aug 1, 2024
17 checks passed
@lakesare lakesare deleted the lakesare/allowedFileTypes-should-be-a-string branch August 1, 2024 10:18
@github-actions github-actions bot mentioned this pull request Aug 15, 2024
github-actions bot added a commit that referenced this pull request Aug 16, 2024
| Package                | Version | Package                | Version |
| ---------------------- | ------- | ---------------------- | ------- |
| @uppy/aws-s3           |   4.0.3 | @uppy/provider-views   |   4.0.1 |
| @uppy/companion        |   5.0.5 | @uppy/status-bar       |   4.0.2 |
| @uppy/companion-client |   4.0.1 | @uppy/transloadit      |   4.0.2 |
| @uppy/core             |   4.1.1 | @uppy/tus              |   4.0.1 |
| @uppy/dashboard        |   4.0.3 | @uppy/utils            |   6.0.2 |
| @uppy/drag-drop        |   4.0.2 | @uppy/vue              |   2.0.1 |
| @uppy/file-input       |   4.0.1 | uppy                   |   4.1.1 |
| @uppy/image-editor     |   3.0.1 |                        |         |

- @uppy/transloadit: fix issue with `allowMultipleUploadBatches` (Mikael Finstad / #5400)
- meta: Bump elliptic from 6.5.5 to 6.5.7 (dependabot[bot] / #5410)
- meta: add back patch for `p-queue` (Antoine du Hamel / #5409)
- @uppy/transloadit: fix many lurking `TypeError` (Mikael Finstad / #5399)
- docs: improve `corsOrigins` documentation (Mikael Finstad / #5390)
- docs: add `ViewEncapsulation` to Angular example (Aaron Russell / #5395)
- @uppy/companion: fix code for custom providers (Mikael Finstad / #5398)
- docs: add note about throwing in `cancelAll` and `destroy()` (Mikael Finstad / #5408)
- meta: Bump docker/login-action from 3.2.0 to 3.3.0 (dependabot[bot] / #5372)
- meta: Bump docker/setup-qemu-action from 3.1.0 to 3.2.0 (dependabot[bot] / #5370)
- docs: make hosted Companion more clear (Merlijn Vos / #5394)
- meta: Bump docker/build-push-action from 6.4.1 to 6.6.1 (dependabot[bot] / #5403)
- meta: bump p-queue to latest, remove patch (Mikael Finstad / #5391)
- meta: enforce `.ts` extension for relative import types (Antoine du Hamel / #5393)
- @uppy/tus: Fix onShouldRetry type signature (Trent Nadeau / #5387)
- @uppy/dashboard,@uppy/drag-drop,@uppy/file-input: Transform the `accept` prop into a string everywhere (Evgenia Karunus / #5380)
- docs: fix getTemporarySecurityCredentials in aws-s3 (Merlijn Vos / #5363)
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.

2 participants