Skip to content

move hx-trigger response header timing to after swap#3900

Open
MichaelWest22 wants to merge 1 commit into
bigskysoftware:four-devfrom
MichaelWest22:hx-trigger-timing
Open

move hx-trigger response header timing to after swap#3900
MichaelWest22 wants to merge 1 commit into
bigskysoftware:four-devfrom
MichaelWest22:hx-trigger-timing

Conversation

@MichaelWest22

Copy link
Copy Markdown
Collaborator

Description

we removed the hx-trigger-after-swap and hx-trigger-after-settle response headers as having 3 of the same thing is not really justified. Now in htmx4 settle delay defaults to 1ms and swap normally happens straight away. Since we now how only one hx-trigger to simplify things I tihnk it is better to move the triggering to after the request completes. I've moved it to the finally stage so it triggers even if hx-location etc fires. By having it trigger after the swap at the end we can cover the use cases for the old after-swap and after-settle with this one header and the only downside is you can't fire the manual trigger before the swap happens. But in practice there is little need for a before swap trigger as the only reason to need this is to perform a custom action before removing some content with a swap and this kind of action would be much easier to be performed with a client side event listener for a htmx:before:swap type event rather than a hx-trigger header.

With this change all users who had after triggers can just move to using the single hx-trigger hopefully.

Corresponding issue:

Testing

moved one test

Checklist

  • I have read the contribution guidelines
  • I have targeted this PR against the correct branch (master for website changes, dev for
    source changes)
  • This is either a bugfix, a documentation update, or a new feature that has been explicitly
    approved via an issue
  • I ran the test suite locally (npm run test) and verified that it succeeded

@MichaelWest22 MichaelWest22 added the htmx 4 Issues specific to htmx version 4 label Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

htmx 4 Issues specific to htmx version 4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant