Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[htmx4] HTMX errors if HX-Trigger Event Detail is null

Closed Beginner friendly
#4,135 3 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 4 days

@MichaelWest22 is already working on this.

Since Oct 15, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
javascript
Domain
frontend

Research direction

Start by reading the trigger method shown in the issue and the documentation for the HX-Trigger response header. Check the tests covering trigger event details, then reproduce a response with no detail object. Done when that response no longer causes an error and the existing event behavior still passes its tests.

Written by the indexing model from the issue text.

Description

If the server returns a HX-Trigger header response with no Detail object then htmx fails here

        trigger(on, eventName, detail = {}, bubbles = true) {
            on = this.#normalizeElement(on)
            let evt = new CustomEvent(eventName, {
                detail,
                cancelable: true,
                bubbles,
                composed: true
            });
            let target = on?.isConnected ? on : document;
            let result = !detail.cancelled && target.dispatchEvent(evt);  <--- Error here
            return result
        }

with a htmx:error: can't access property "cancelled", detail is null

The documentation suggests that the detail object is optional so I think the line needs a guard statement?

Dominant language
JavaScript
Stars
49.6k
Forks
1.7k
Avg merge
9d 3h
Merged PRs (30d)
10

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bigskysoftware/htmx

All issues in bigskysoftware/htmx

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.