Summary
pageDropTarget (kmp/src/wasmJsMain/kotlin/dev/stapler/stelekit/ui/components/PageDropTarget.kt) returns the unmodified Modifier on WASM. Dragging an image file onto a page on the web target does nothing.
Root cause
Compose Multiplatform for WASM renders entirely into a single <canvas> element. HTML5 drag events (dragenter, dragover, drop) fire on the canvas DOM element, not on individual Compose composables. There is no supported Compose WASM API to intercept these events and route them into the onFilesDropped: (List<Any>) -> Unit callback.
The JVM implementation uses AWT DropTarget which maps natively into the component hierarchy — that mechanism doesn't exist on WASM.
Proposed fix
Add a JS drop event listener on document.querySelector('canvas') (or the Compose viewport element), extract the DataTransfer.files list, read each file as an ArrayBuffer, and post the result back to a Kotlin-side callback via a shared channel (e.g., a Channel<List<JsAny>> consumed by a coroutine in Main.kt). This requires threading the callback through Main.kt and connecting it to the modifier via a CompositionLocal.
Affected files
kmp/src/wasmJsMain/kotlin/dev/stapler/stelekit/ui/components/PageDropTarget.kt
kmp/src/commonMain/kotlin/dev/stapler/stelekit/ui/components/PageDropTargetModifier.kt
kmp/src/wasmJsMain/kotlin/dev/stapler/stelekit/browser/Main.kt
Labels
bug, platform: web, needs-design
Summary
pageDropTarget(kmp/src/wasmJsMain/kotlin/dev/stapler/stelekit/ui/components/PageDropTarget.kt) returns the unmodifiedModifieron WASM. Dragging an image file onto a page on the web target does nothing.Root cause
Compose Multiplatform for WASM renders entirely into a single
<canvas>element. HTML5 drag events (dragenter,dragover,drop) fire on the canvas DOM element, not on individual Compose composables. There is no supported Compose WASM API to intercept these events and route them into theonFilesDropped: (List<Any>) -> Unitcallback.The JVM implementation uses AWT
DropTargetwhich maps natively into the component hierarchy — that mechanism doesn't exist on WASM.Proposed fix
Add a JS
dropevent listener ondocument.querySelector('canvas')(or the Compose viewport element), extract theDataTransfer.fileslist, read each file as anArrayBuffer, and post the result back to a Kotlin-side callback via a shared channel (e.g., aChannel<List<JsAny>>consumed by a coroutine inMain.kt). This requires threading the callback throughMain.ktand connecting it to the modifier via aCompositionLocal.Affected files
kmp/src/wasmJsMain/kotlin/dev/stapler/stelekit/ui/components/PageDropTarget.ktkmp/src/commonMain/kotlin/dev/stapler/stelekit/ui/components/PageDropTargetModifier.ktkmp/src/wasmJsMain/kotlin/dev/stapler/stelekit/browser/Main.ktLabels
bug,platform: web,needs-design