@@ -78,9 +78,20 @@ const getAcceptedMimeTypes = (resourceKind: ResourceKind): string[] => {
7878 return resourceKindToInputAcceptedMimes [ resourceKind ] || [ ] ;
7979} ;
8080
81+ const usesFilePseudoMime = ( resourceKind : ResourceKind ) : boolean => {
82+ const acceptedMimes = getAcceptedMimeTypes ( resourceKind ) ;
83+ return acceptedMimes . length === 1 && acceptedMimes [ 0 ] === 'file' ;
84+ } ;
85+
8186export const getInputAcceptedMimesAndExtensions = (
8287 resourceKind : ResourceKind
8388) : string => {
89+ // iOS Safari/WKWebView maps each extension of the `accept` attribute to a mime type,
90+ // dropping the unrecognized ones. If at least one is recognized (like .xml), the picker
91+ // is restricted to it, greying out the others (like .fnt). So when the 'file' pseudo-mime
92+ // is used, don't send any extension: validation happens post-picking.
93+ if ( usesFilePseudoMime ( resourceKind ) ) return 'file' ;
94+
8495 const acceptedExtensions = getAcceptedExtensions ( resourceKind ) ;
8596 const acceptedMimes = getAcceptedMimeTypes ( resourceKind ) ;
8697
@@ -205,11 +216,9 @@ export const FileToCloudProjectResourceUploader = ({
205216
206217 const shouldValidateFilePostPicking = React . useMemo (
207218 ( ) => {
208- const acceptedMimeTypes = getAcceptedMimeTypes ( options . resourceKind ) ;
209- // Safari does not use file extensions to filter files pre-picking and
210- // Safari also does not recognize all mime types. So if the only accepted
211- // mime type is 'file', the file validation should happen post-picking.
212- return acceptedMimeTypes . length === 1 && acceptedMimeTypes [ 0 ] === 'file' ;
219+ // If the only accepted mime type is the 'file' pseudo-mime, no filtering
220+ // happens pre-picking, so the file validation should happen post-picking.
221+ return usesFilePseudoMime ( options . resourceKind ) ;
213222 } ,
214223 [ options . resourceKind ]
215224 ) ;
0 commit comments