diff --git a/packages/upload/src/vaadin-upload-file-mixin.js b/packages/upload/src/vaadin-upload-file-mixin.js index 3fa8c7a1e4..763d13970c 100644 --- a/packages/upload/src/vaadin-upload-file-mixin.js +++ b/packages/upload/src/vaadin-upload-file-mixin.js @@ -161,12 +161,16 @@ export const UploadFileMixin = (superClass) => * @protected */ _shouldSetFocus(event) { - return !this.disabled && event.composedPath()[0] === this; + return event.composedPath()[0] === this; } /** @private */ __disabledChanged(disabled) { - this.tabIndex = disabled ? -1 : 0; + if (disabled) { + this.removeAttribute('tabindex'); + } else { + this.setAttribute('tabindex', this.tabindex); + } } /** @private */ diff --git a/packages/upload/test/file.common.js b/packages/upload/test/file.common.js index 3765993da4..d287436e25 100644 --- a/packages/upload/test/file.common.js +++ b/packages/upload/test/file.common.js @@ -82,12 +82,15 @@ describe(' element', () => { it('should be focusable by default', () => { fileElement.focus(); expect(fileElement.hasAttribute('focused')).to.be.true; + expect(document.activeElement).to.equal(fileElement); }); - it('should not be focusable when disabled', () => { + it('should not be focusable when disabled', async () => { fileElement.disabled = true; + await nextUpdate(fileElement); fileElement.focus(); expect(fileElement.hasAttribute('focused')).to.be.false; + expect(document.activeElement).to.not.equal(fileElement); }); it('should not add focus-ring to the host on programmatic focus', () => {