Skip to content

Commit a51049b

Browse files
authored
Minimal fix for missed pointerup after drug in Safari (JetBrains#3011)
This is the most possible non-invasive way to fix the bug that exists in safari with processing pointer events after drag cancellation ## Testing manual ## Release Notes ### Fixes - Web - [CMP-10102](https://youtrack.jetbrains.com/issue/CMP-10102) [Web] Safari. DragAndDrop. After performing drag and drop operations buttons are unclickable on the first attempt
1 parent f79cd2a commit a51049b

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

compose/mpp/demo/src/webMain/kotlin/androidx/compose/mpp/demo/components/DragAndDropExample.web.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ import androidx.compose.ui.text.input.TextFieldValue
6767
actual fun DragAndDropExample() {
6868
val exportedText = "Hello, DnD!"
6969

70-
var isTargetEnabled by remember { mutableStateOf(false) }
70+
var isTargetEnabled by remember { mutableStateOf(true) }
7171

7272

7373
Box(

compose/ui/ui/src/webMain/kotlin/androidx/compose/ui/window/ComposeWindowInternal.web.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ internal class ComposeWindow(
376376
}
377377

378378
private fun initEvents(canvas: HTMLCanvasElement) {
379+
379380
listOf(
380381
"pointerenter",
381382
"pointerdown",
@@ -387,6 +388,12 @@ internal class ComposeWindow(
387388
addTypedEvent<PointerEvent>(name, passive = false) { onPointerEvent(it) }
388389
}
389390

391+
state.globalEvents.addDisposableEvent("dragend") {
392+
// in Safari pointerup event is not firing when we drop or cancel drop
393+
// see https://youtrack.jetbrains.com/issue/CMP-10102
394+
actualActivePointerButtons = null
395+
}
396+
390397
addTypedEvent<TouchEvent>("touchstart") { evt ->
391398
// in most cases we don't care about touches since in Compose we do not process them at all
392399
// there's one case however when we need to cancel them - it's when we are focussed in a DOM backing field

0 commit comments

Comments
 (0)