Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HX-Redirect causing indicators to clear before redirect #2779

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion src/htmx.js
Original file line number Diff line number Diff line change
Expand Up @@ -4343,7 +4343,9 @@
const hierarchy = hierarchyForElt(elt)
responseInfo.pathInfo.responsePath = getPathFromResponse(xhr)
responseHandler(elt, responseInfo)
removeRequestIndicators(indicators, disableElts)
if (!hasHeader(xhr, /HX-Redirect:/i)) {
removeRequestIndicators(indicators, disableElts);

Check failure on line 4347 in src/htmx.js

View workflow job for this annotation

GitHub Actions / test_suite

Extra semicolon
}
triggerEvent(elt, 'htmx:afterRequest', responseInfo)
triggerEvent(elt, 'htmx:afterOnLoad', responseInfo)
// if the body no longer contains the element, trigger the event on the closest parent
Expand Down Expand Up @@ -4949,6 +4951,38 @@
}
}
}

window.addEventListener("pageshow", (event) => {

Check failure on line 4955 in src/htmx.js

View workflow job for this annotation

GitHub Actions / test_suite

Strings must use singlequote
if (event.persisted) {
let indicators = document.querySelectorAll("[hx-indicator]");

Check failure on line 4957 in src/htmx.js

View workflow job for this annotation

GitHub Actions / test_suite

'indicators' is never reassigned. Use 'const' instead

Check failure on line 4957 in src/htmx.js

View workflow job for this annotation

GitHub Actions / test_suite

Strings must use singlequote

Check failure on line 4957 in src/htmx.js

View workflow job for this annotation

GitHub Actions / test_suite

Extra semicolon

indicators.forEach((indicator) => {
let indicators = /** @type Element[] */ (
findAttributeTargets(indicator, "hx-indicator")

Check failure on line 4961 in src/htmx.js

View workflow job for this annotation

GitHub Actions / test_suite

Strings must use singlequote
);

Check failure on line 4962 in src/htmx.js

View workflow job for this annotation

GitHub Actions / test_suite

Extra semicolon
if (indicators == null) {
indicators = [];

Check failure on line 4964 in src/htmx.js

View workflow job for this annotation

GitHub Actions / test_suite

Extra semicolon
}
forEach(indicators, function (indicator) {

Check failure on line 4966 in src/htmx.js

View workflow job for this annotation

GitHub Actions / test_suite

Unexpected space before function parentheses
indicator.classList.remove(htmx.config.requestClass);

Check failure on line 4967 in src/htmx.js

View workflow job for this annotation

GitHub Actions / test_suite

Extra semicolon
});
});

let disabledElts = document.querySelectorAll("[hx-disabled-elt]");
disabledElts.forEach((eltTargets) => {
let disabledElts = /** @type Element[] */ (
findAttributeTargets(eltTargets, "hx-disabled-elt")
);
if (disabledElts == null) {
disabledElts = [];
}
forEach(disabledElts, function (disabledElement) {
disabledElement.removeAttribute("disabled");
});
});
}
});

getWindow().setTimeout(function() {
triggerEvent(body, 'htmx:load', {}) // give ready handlers a chance to load up before firing this event
body = null // kill reference for gc
Expand Down