Skip to content
This repository was archived by the owner on Dec 17, 2025. It is now read-only.

Commit b20fd4d

Browse files
Lysanderchristian.hausknecht
andauthored
Fixes a small potential bug on headless switch component (#933)
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>
1 parent 32dacf2 commit b20fd4d

File tree

1 file changed

+4
-1
lines changed
  • headless/src/jsMain/kotlin/dev/fritz2/headless/components

1 file changed

+4
-1
lines changed

headless/src/jsMain/kotlin/dev/fritz2/headless/components/Switch.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ abstract class AbstractSwitch<C : HTMLElement>(
3535
attr(Aria.checked, enabled.asString())
3636
attr(Aria.invalid, "true".whenever(value.hasError))
3737
attr("tabindex", "0")
38-
value.handler?.invoke(this, clicks.map { !value.data.first() })
38+
value.handler?.invoke(this, clicks {
39+
stopImmediatePropagation()
40+
preventDefault()
41+
}.map { !value.data.first() })
3942
value.handler?.invoke(
4043
this,
4144
keydownsIf {

0 commit comments

Comments
 (0)