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
|
# rubocop:enable Rails/OutputSafety
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def focus_element(selector)
|
||||||
|
# rubocop:disable Rails/OutputSafety
|
||||||
|
raw("document.querySelector('#{selector}').focus();")
|
||||||
|
# rubocop:enable Rails/OutputSafety
|
||||||
|
end
|
||||||
|
|
||||||
def disable_element(selector)
|
def disable_element(selector)
|
||||||
# rubocop:disable Rails/OutputSafety
|
# rubocop:disable Rails/OutputSafety
|
||||||
raw("document.querySelector('#{selector}').disabled = true;")
|
raw("document.querySelector('#{selector}').disabled = true;")
|
||||||
|
|
|
@ -25,6 +25,7 @@ export default class ProgressBar {
|
||||||
const element = getDirectUploadElement(id);
|
const element = getDirectUploadElement(id);
|
||||||
if (element) {
|
if (element) {
|
||||||
element.classList.remove(PENDING_CLASS);
|
element.classList.remove(PENDING_CLASS);
|
||||||
|
element.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,3 +4,5 @@
|
||||||
<% if attachment.virus_scanner.pending? %>
|
<% 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 ) %>
|
<%= fire_event('attachment:update', { url: attachment_url(attachment.id, { signed_id: attachment.blob.signed_id, user_can_upload: true }) }.to_json ) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<%= focus_element("button[data-toggle-target=\".attachment-input-#{attachment.id}\"]") %>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue