JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.24k stars 1.18k forks source link

iOS: TabView > UITableViewController > UIHostingController > Compose Configuration Causes Recompose and Horizontal Scroll Issues #3879

Closed 75py closed 1 month ago

75py commented 1 year ago

Describe the bug When integrating Compose Multiplatform within an iOS project that uses TabView (SwiftUI), UITableViewController, and UIHostingController, I experience the following issues:

  1. Recomposition does not occur when pressing a button to change text in a Compose view. However, recomposition happens when I scroll the UITableView.
  2. Horizontal scrolling is disabled in Compose views.

Affected platforms

Versions

To Reproduce

  1. Clone the minimum project at https://github.com/75py/Multiplatform-Sandbox
  2. Navigate to the tab containing the UITableView.
  3. Try clicking on a button inside the Compose view; observe that the text doesn't change.
  4. Try scrolling horizontally; observe that horizontal scrolling is disabled.
  5. Scroll the UITableView; observe that recomposition happens.

Main Code Files

Expected behavior

  1. The Compose view should recompose when pressing a button to change text.
  2. Horizontal scrolling should work as expected in Compose views.

Screenshots

https://github.com/JetBrains/compose-multiplatform/assets/3153211/f4b604ce-1d7b-4b4d-88db-5d1314e631b6

Additional context The issue seems to occur only when using this specific configuration of TabView, UITableViewController, and UIHostingController.

m-sasha commented 1 year ago

LazyRow is already scrollable. You don't need to add a horizontalScroll modifier to it.

75py commented 1 year ago

@m-sasha Thank you for the quick response. I've removed the horizontalScroll modifier from LazyRow as you suggested and pushed the changes. However, the issue still persists. Horizontal scrolling is not enabled in the Compose view.

Here is the commit where I made the changes: https://github.com/75py/Multiplatform-Sandbox/commit/f925bcd4ac7cdb78e58dfd407245f74625de3bb8

Would appreciate any further guidance on this.

75py commented 9 months ago

I've recently updated the Compose plugin to version 1.6.0-beta01, and I'd like to share some updates regarding the issues previously reported:

  1. The issue where the Compose view did not recompose when pressing a button to change text has been resolved with this update. This fix significantly improves the user interaction within Compose views on iOS.

  2. Unfortunately, the problem with horizontal scrolling being disabled in Compose views remains unresolved. This continues to affect the usability of horizontally scrollable components in our iOS application.

You can view the changes made in this update here: Tag Link.

I hope this information helps in tracking the progress of these issues. Looking forward to any suggestions or further updates on the unresolved matter.

https://github.com/JetBrains/compose-multiplatform/assets/3153211/ccc81e30-245b-45d1-8b05-9dc654880fc5

tipsypotato commented 8 months ago

Same here, looking forward to any workaround

okushnikov commented 4 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.