LPology / Simple-Ajax-Uploader

Javascript file upload plugin with progress bar support. Works in all major browsers, including IE7+, Chrome, Firefox, Safari, and Opera. No dependencies - use it with or without jQuery.
995 stars 267 forks source link

Add keyboard support with file button #183

Closed phy25 closed 7 years ago

phy25 commented 7 years ago

Test case: Use Tab to focus on select file button, and hit Enter.

This should be handled.

LPology commented 7 years ago

Merging. Thanks for your contribution.

LPology commented 7 years ago

I'm about to push a new release. I made a couple of small changes to your code, just fyi.

  1. Added precaution check for e.preventDefault (line 1062, approx):
if ( e && e.preventDefault ) {
    e.preventDefault();
}
  1. Added check for Internet Explorer (IE7-9 does not allow elem.click() on invisible file elements):

Line 49 (approx):

    isIE7to9 = ( navigator.userAgent.indexOf('MSIE') !== -1 &&
                 navigator.userAgent.indexOf('MSIE 1') === -1 ),

Line 1076 (approx):

if ( !isIE7to9 ) {
    self._input.click();
}

This allows the previous behavior to continue in IE7-9, otherwise an error will occur and uploads will not work until the page is reloaded.

phy25 commented 7 years ago

Fine. I didn't consider IE issue yet, so that's good.