Skip to content

Business intelligence made simple

Restored autofocus with back button [skip ci]

Andrew Kane3bf64d3686c2
diff --git a/app/assets/javascripts/blazer/application.js b/app/assets/javascripts/blazer/application.js
index 51aa2391..66f6c6b5 100644
--- a/app/assets/javascripts/blazer/application.js
+++ b/app/assets/javascripts/blazer/application.js
@@ -62,6 +62,16 @@ document.addEventListener("click", function (e) {
}
})
+// make autofocus work with back button
+window.addEventListener("pageshow", function (e) {
+ if (e.persisted) {
+ const element = document.querySelector("input[autofocus]")
+ if (element) {
+ element.focus()
+ }
+ }
+})
+
function submitIfCompleted(form) {
let completed = true
for (const input of form.querySelectorAll("input[name], select")) {