handle focus during and after upload
This commit is contained in:
parent
43039d1755
commit
df3bd3a1d2
3 changed files with 9 additions and 0 deletions
|
@ -79,6 +79,12 @@ module ApplicationHelper
|
|||
# rubocop:enable Rails/OutputSafety
|
||||
end
|
||||
|
||||
def focus_element(selector)
|
||||
# rubocop:disable Rails/OutputSafety
|
||||
raw("document.querySelector('#{selector}').focus();")
|
||||
# rubocop:enable Rails/OutputSafety
|
||||
end
|
||||
|
||||
def disable_element(selector)
|
||||
# rubocop:disable Rails/OutputSafety
|
||||
raw("document.querySelector('#{selector}').disabled = true;")
|
||||
|
|
|
@ -25,6 +25,7 @@ export default class ProgressBar {
|
|||
const element = getDirectUploadElement(id);
|
||||
if (element) {
|
||||
element.classList.remove(PENDING_CLASS);
|
||||
element.focus();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,3 +4,5 @@
|
|||
<% if attachment.virus_scanner.pending? %>
|
||||
<%= fire_event('attachment:update', { url: attachment_url(attachment.id, { signed_id: attachment.blob.signed_id, user_can_upload: true }) }.to_json ) %>
|
||||
<% end %>
|
||||
|
||||
<%= focus_element("button[data-toggle-target=\".attachment-input-#{attachment.id}\"]") %>
|
||||
|
|
Loading…
Add table
Reference in a new issue