From 6e3c765ba308091c9732e37545f6ef4b6c46aba7 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Mon, 16 Jan 2023 09:54:21 +0200 Subject: [PATCH] attachment focus fix --- client/src/views/fields/attachment-multiple.js | 11 ++++++++++- client/src/views/fields/file.js | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/client/src/views/fields/attachment-multiple.js b/client/src/views/fields/attachment-multiple.js index 496032ee5c..866a6128ef 100644 --- a/client/src/views/fields/attachment-multiple.js +++ b/client/src/views/fields/attachment-multiple.js @@ -575,7 +575,16 @@ function (Dep, FileUpload) { this.isUploading = false; - setTimeout(() => this.focusOnUploadButton(), 50); + setTimeout(() => { + if ( + document.activeElement && + document.activeElement.tagName !== 'BODY' + ) { + return; + } + + this.focusOnUploadButton(); + }, 50); } }) .catch(() => { diff --git a/client/src/views/fields/file.js b/client/src/views/fields/file.js index 533d2ee19e..d06866d496 100644 --- a/client/src/views/fields/file.js +++ b/client/src/views/fields/file.js @@ -604,6 +604,13 @@ define('views/fields/file', ['views/fields/link', 'helpers/file-upload'], functi this.isUploading = false; setTimeout(() => { + if ( + document.activeElement && + document.activeElement.tagName !== 'BODY' + ) { + return; + } + let $a = this.$el.find('.preview a'); $a.focus(); }, 50);