Skip to content

Commit

Permalink
Fixes a small potential bug on headless switch component (#933)
Browse files Browse the repository at this point in the history
The `click`-event is now correctly handled by stop propagating it and `preventDefault` as the headless component will do all the work.

This could have led to bugs when using the component with explicit `DataBinging`, where the `handler`-lambda would be used to intercept the update call.

Co-authored-by: christian.hausknecht <christian.hausknecht@oeffentliche.de>
  • Loading branch information
Lysander and christian.hausknecht authored Jan 31, 2025
1 parent 32dacf2 commit b20fd4d
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ abstract class AbstractSwitch<C : HTMLElement>(
attr(Aria.checked, enabled.asString())
attr(Aria.invalid, "true".whenever(value.hasError))
attr("tabindex", "0")
value.handler?.invoke(this, clicks.map { !value.data.first() })
value.handler?.invoke(this, clicks {
stopImmediatePropagation()
preventDefault()
}.map { !value.data.first() })
value.handler?.invoke(
this,
keydownsIf {
Expand Down

0 comments on commit b20fd4d

Please sign in to comment.