Files
headlessui/packages/@headlessui-react/src/utils
Robin Malfait 33a5893e4f Improve cancellation of events when using disabled or aria-disabled attributes (#2890)
* only cancel certain events when disabled

The initial idea was that whenever an element had the `disabled` or
`aria-disabled` prop/attribute that we were going to remove all the
event listeners.

However, this is not ideal because in some scenario's we were actually
explicitly adding `onClick()` listeners (for `<a>` elements) to
`e.preventDefault()` when the link was marked as "disabled" to prevent
it executing the actual link click.

This commit will allow all defined listeners as-is, however, if you are
using one of the following event listeners:

- `onClick`
- `onPointerUp`
- `onPointerDown`
- `onMouseUp`
- `onMouseDown`
- `onKeyUp`
- `onKeyPress`
- `onKeyDown`

Then we will replace it with `(e) => e.preventDefault()` instead.

This way we are still invoking your own listeners, but are explicitly
calling `e.preventDefault()` on listeners that should not be executed in
the first place when an element is `disabled`.

* update CHANGELOG.md

* update CHANGELOG.md
2023-12-21 00:09:08 +01:00
..
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2022-03-09 11:24:45 +01:00
2021-01-30 14:46:54 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00
2023-12-20 19:57:57 +01:00