Skip to content

Conversation

msynowski
Copy link

@msynowski msynowski commented Oct 5, 2025

Description

Currently, when navigating back to a screen containing a Compose-based view, lastFocusedChild is assigned to the internal AndroidComposeView leaving the screen without any focused element.

Instead of targeting the internal AndroidComposeView, Screens would restore it now to it's Android layout parent, that all custom RN views have, allowing developers to restore it back to compose via listeners or overriding the requestFocus method.

Changes

Restore focus from Jetpack Compose views to the parent Android layout, allowing to redirect it back to Compose via focus listeners/overriding requestFocus

@kkafar kkafar self-requested a review October 6, 2025 10:04

private fun isComposeView(view: View): Boolean {
val name = view.javaClass.name
return name.startsWith("androidx.compose.ui.platform.")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found out it doesn't work in release mode - R8 strips class names.

Normally I'd just check if view is instance of a compose class, however here adding compose as a dependency doesn't seem an option.

Looking forward to some advice on how to tackle this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best solution would be adding proguard rules to keep compose classes - lmk if you're cool with it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good that you catched this.

Isn't proguard configured on the app level? This is not really a proper solution from the library perspective & I'd like to avoid additional installation steps here.

I'll try to come up with something sensible when doing review & testing this.

I've withheld myself with review, before I fully understand the code & see the issue firsthand first. I'll be on PTO until end of the week. On Monday I'll try to do a proper testing & review here.

Copy link
Author

@msynowski msynowski Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't proguard configured on the app level?

Yup. There's this thing called consumerProguardFiles, but it only works when the dependency is distributed as AAR and that's unfortunately not the case

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Monday I'll try to do a proper testing & review here.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants