Allow HX-Location to control indicator cleanup - #4091
Ai-Eastern wants to merge 2 commits into
Conversation
|
@MichaelWest22 I've updated this PR based on your suggestion: the existing behavior is preserved by default, while |
|
@Ai-Eastern thanks. i've had another look and I think we can maybe do a better solution to just get hx-location to pass the indicators and disabled elements down to the next ajax request in a chain so it can tidy them up naturally. This avoid having to know to set keepIndicators manually when required as i had originally suggested. Opened #4097 with this version |
|
Thanks for taking another look. Passing the existing indicator and disabled-element state through the HX-Location request chain is cleaner and avoids requiring callers to opt into cleanup manually. Closing this in favor of #4097. |
Description
Preserve the existing
HX-Locationbehavior by default, while allowing partial-page redirects to opt out withkeepIndicators:falsein theHX-LocationJSON or HCON options.When disabled, the original request cleans up its indicators and re-enables disabled elements after issuing the follow-up request. The option is consumed by the response-header handler and is not forwarded to the follow-up
htmx.ajax()call.Adds regression coverage for the default and opt-out behavior, guards
HX-Refresh/HX-Redirect, and documents the new option.Fixes #4090
Testing
npm test -- test/tests/unit/__handleHxHeadersAndMaybeReturnEarly.js— 15 passed, 1 expected failure before the implementation.npm test -- test/tests/unit/__handleHxHeadersAndMaybeReturnEarly.js— 16 passed, 0 failed.npm test -- test/tests/unit/__handleHxHeadersAndMaybeReturnEarly.js test/tests/attributes/hx-indicator.js— 21 passed, 0 failed.npm test— 1784 passed, 0 failed, 4 skipped.git diff --check.npm run check:content— all source, extension API documentation, and web-types checks passed (using the bundled Python runtime with UTF-8 mode).No generated
distfiles are included.