The fake hover state conflicts with the file dialog, which does not blur the input field, causing the button to be visually stuck in the hover state.
This change still renders the focus style when the dialog is opened via keyboard navigation.
elAttr($button[0], 'role', 'button');
$button.prepend(this._fileUpload);
- this._fileUpload[0].addEventListener('focus', function() { $button[0].classList.add('active'); });
+ this._fileUpload[0].addEventListener('focus', function() {
+ if (this.classList.contains('focus-visible')) {
+ $button[0].classList.add('active');
+ }
+ });
this._fileUpload[0].addEventListener('blur', function() { $button[0].classList.remove('active'); });
}
else {
this._button.className = 'button uploadButton';
elAttr(this._button, 'role', 'button');
- this._fileUpload.addEventListener('focus', (function() { this._button.classList.add('active'); }).bind(this));
+ this._fileUpload.addEventListener('focus', (function() {
+ if (this._fileUpload.classList.contains('focus-visible')) {
+ this._button.classList.add('active');
+ }
+ }).bind(this));
this._fileUpload.addEventListener('blur', (function() { this._button.classList.remove('active'); }).bind(this));
var span = elCreate('span');