KevinnZou / compose-webview-multiplatform

WebView for JetBrains Compose Multiplatform
https://kevinnzou.github.io/compose-webview-multiplatform/
Apache License 2.0
318 stars 40 forks source link

Brakes scroll of parent, only ios #155

Open AttilaBarany opened 2 weeks ago

AttilaBarany commented 2 weeks ago

Hi. Any chance to fix this issue? Some webviews needed to be displayed in a regular scrollable column in my project. Or do I miss maybe a setting which can fix this issue? On Android I can scroll down the column easily even if I drag the webview, but not on iOS. It scrolls only if I drag outside the webview. Which is not possible eg if the webview is higher than the screen height. Then every other content of the column after the webview will be unreachable:(. I also tried overflow hidden on the webpage, did not help. Also set webViewState.webSettings.iOSWebSettings.scrollEnabled = false for a try, but it just changed the scrollablity of the html content inside the webview. In normal case in swiftui and wkwebview works together smoothly.

To reproduce:

Screenshot 2024-05-15 at 12 21 31
KevinnZou commented 2 weeks ago

@AttilaBarany The issue is related to nested scrolling and is not a problem with this library. You can refer to this reply and try to implement nestedscroll functionality.

AttilaBarany commented 2 weeks ago

@KevinnZou Thanks for the fast reply. The problem is just the opposite. Yes, nestedscroll did have problems in compose with Androidview, where parent steels the scroll event, we can read a lot about it on stackoverflow too. But here, the child (webview) steels all the events from the parent on ios. I tried to add ondrag, customnestedscroll etc... to the webview directly, and does not trigger anything on ios. I could not get a single println of them. The event stucks somewhere inside the lib. So actually this looks a library problem on ios platform. This is a big limitation that on iOS you can not use it, just with full screen, where no other components needed to display.

KevinnZou commented 2 weeks ago

@AttilaBarany Thanks for your information! I do not have time to check it deeply currently. But I think nestscroll modifier should solve your issue. You just need to intercept the scroll of webview first and then check whether webview can scroll. If it cannot, then pass the scroll event to the parent. I would recommend you check this lib. Could you please provide the code for the custom nested scroll?

AttilaBarany commented 2 weeks ago

@KevinnZou Thanks, but I was digging deeper, and found out, the problem happens with every UIKitView (I beleive you use that one too for ios wkwebview), even with just a single UIView(). So I filed a ticket at compose multiplatform. It is such a basic functionality, and I think the whole UIKitView thing worth nothing without having them in scrollable views. Btw Flutter was suffering from the same thing before, I dont know if still do. You can follow the issue if interested, they are saying they know about it, and trying to resolve: https://github.com/JetBrains/compose-multiplatform/issues/4818 I think you can close this ticket, or maybe need some adjustment later once they find a solution for the original problem. Thanks!:)