Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Android): Request layout manually for CustomToolbar below Android API 29 #2332

Merged
merged 2 commits into from
Sep 12, 2024

Conversation

tboba
Copy link
Member

@tboba tboba commented Sep 3, 2024

Description

On Android API 29, while using windowSoftInputMode with adjustPan option, requestLayout is not being called while subviews are being added. That's because while ScreenStackHeaderConfig adds view to the toolbar, onMeasure is being called and even if we're calling requestLayout on parent, Android is returning from requesting the layout, as there's somehow ongoing layout. This is not the case for Android API 30 and higher.

The solution is to request another layout via ReactChoreographer (same as in ScreenContainer) to call our own layout callback on the next frame.

Changes

  • Request layout via ReactChoreographer on requestLayout call in CustomToolbar class

Screenshots / GIFs

BEFORE

CleanShot 2024-09-03 at 17 59 13

AFTER

CleanShot 2024-09-03 at 17 51 14

Test code and steps to reproduce

Use Test2332.tsx test case to check whether this PR works properly.

Checklist

  • Included code example that can be used to test this change
  • Ensured that CI passes

tboba and others added 2 commits September 3, 2024 18:06
…ow Android API 29

Co-authored-by: Kacper Kafara <kacper.kafara@swmansion.com>
@tboba tboba force-pushed the @tboba/fix-android-adjustpan-layout branch from b277f6c to e3972d7 Compare September 3, 2024 16:07
Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

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

👍🏻 We came out with this solution on a call, tested it, can proceed.

@kkafar kkafar merged commit d394e2c into main Sep 12, 2024
4 checks passed
@kkafar kkafar deleted the @tboba/fix-android-adjustpan-layout branch September 12, 2024 07:27
@kkafar kkafar restored the @tboba/fix-android-adjustpan-layout branch September 12, 2024 07:27
@tboba tboba deleted the @tboba/fix-android-adjustpan-layout branch September 12, 2024 09:07
ja1ns pushed a commit to WiseOwlTech/react-native-screens that referenced this pull request Oct 9, 2024
… API 29 (software-mansion#2332)

## Description

On Android API 29, while using `windowSoftInputMode` with `adjustPan`
option, requestLayout is not being called while subviews are being
added. That's because while ScreenStackHeaderConfig adds view to the
toolbar, onMeasure is being called and even if we're calling
`requestLayout` on parent, Android is returning from requesting the
layout, as there's somehow ongoing layout. This is not the case for
Android API 30 and higher.

The solution is to request another layout via ReactChoreographer (same
as in ScreenContainer) to call our own layout callback on the next
frame.

## Changes

- Request layout via ReactChoreographer on `requestLayout` call in
CustomToolbar class

## Screenshots / GIFs

<details><summary>BEFORE</summary>

![CleanShot 2024-09-03 at 17 59
13](https://github.com/user-attachments/assets/3f7952a5-6430-4b25-b587-4690fac236d3)

</details>

<details><summary>AFTER</summary>

![CleanShot 2024-09-03 at 17 51
14](https://github.com/user-attachments/assets/f2551b98-5de1-4021-8c72-0e4718aaaf45)

</details>

## Test code and steps to reproduce

Use `Test2332.tsx` test case to check whether this PR works properly.

## Checklist

- [x] Included code example that can be used to test this change
- [ ] Ensured that CI passes

---------

Co-authored-by: Kacper Kafara <kacper.kafara@swmansion.com>
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