Skip to content

Allow HX-Location to control indicator cleanup - #4091

Closed
Ai-Eastern wants to merge 2 commits into
bigskysoftware:four-devfrom
Ai-Eastern:fix/hx-location-indicator
Closed

Ai-Eastern wants to merge 2 commits into
bigskysoftware:four-devfrom
Ai-Eastern:fix/hx-location-indicator

Conversation

@Ai-Eastern

@Ai-Eastern Ai-Eastern commented Sep 21, 2026 •

Copy link
Copy Markdown

Description

Preserve the existing HX-Location behavior by default, while allowing partial-page redirects to opt out with keepIndicators:false in the HX-Location JSON 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

  • RED: npm test -- test/tests/unit/__handleHxHeadersAndMaybeReturnEarly.js — 15 passed, 1 expected failure before the implementation.
  • PASS: npm test -- test/tests/unit/__handleHxHeadersAndMaybeReturnEarly.js — 16 passed, 0 failed.
  • PASS: npm test -- test/tests/unit/__handleHxHeadersAndMaybeReturnEarly.js test/tests/attributes/hx-indicator.js — 21 passed, 0 failed.
  • PASS: npm test — 1784 passed, 0 failed, 4 skipped.
  • PASS: git diff --check.
  • PASS: 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 dist files are included.

@Ai-Eastern
Ai-Eastern marked this pull request as ready for review September 21, 2026 03:21
@Ai-Eastern Ai-Eastern changed the title Fix HX-Location indicators not clearing Allow HX-Location to control indicator cleanup Sep 22, 2026
@Ai-Eastern

Copy link
Copy Markdown
Author

@MichaelWest22 I've updated this PR based on your suggestion: the existing behavior is preserved by default, while HX-Location can now set keepIndicators:false for partial-page replacements. I also added regression tests and documentation. Would you mind taking a look when you have a chance?

@MichaelWest22

Copy link
Copy Markdown
Collaborator

@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

@Ai-Eastern

Copy link
Copy Markdown
Author

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.

@Ai-Eastern Ai-Eastern closed this Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants