bigskysoftware / bigskysoftware/htmx

Checkboxes with `required` attribute don't trigger when unchecking when hx-trigger is at a higher level

Open
#2,782 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
49.4k
Forks
1.7k
Avg merge
3d 22h
Merged PRs (30d)
30

Description

I'm not 100% sure if this is a bug or expected behaviour, but it caused enough confusion that I feel I should at least write an issue. The following situation:

```html



Checkbox test


```

```html

It worked!
```

This works fine when you _check_ the box, but not when you _uncheck_ it.

However, it does work if you put the `hx-` attributes directly on the `input`:

```html



Checkbox test


```

If the checkbox is not required, it also works as expected:

```html



Checkbox test


```

It's interesting to note that `onchange` does trigger a change event in JS, but it seems like HTMX does nothing.

Certainly there was a mistake on our side in requiring checkboxes that can be empty, but I also feel HTMX is doing something unexpected here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.