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): disappearing search icon on opening transparent modal #2274

Merged
merged 9 commits into from
Aug 6, 2024

Conversation

alduzy
Copy link
Member

@alduzy alduzy commented Jul 31, 2024

Description

This PR fixes disappearing search icon of the previous screen when navigating to a transparent modal with hidden header.

When navigating to a screen with presentation: "transparentModal" and headerShown: false the toolbar menu was
unnecessarily updated with new screen's options. The update caused the search icon of the previous screen (still visible in the background) to disappear.

Fixes #2271 .

Changes

  • added Test2271.tsx repro
  • updating the toolbar menu conditionally

Screenshots / GIFs

Before

Screen.Recording.2024-07-31.at.18.42.53.mov

After

Screen.Recording.2024-07-31.at.18.41.43.mov

Test code and steps to reproduce

  • use Test2271.tsx for repro

Checklist

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

@alduzy alduzy requested review from tboba and kkafar July 31, 2024 16:45
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.

Let's have some explanation what was the error mechanism & why the previous code does not work.

@kkafar kkafar self-requested a review July 31, 2024 18:57
@alduzy
Copy link
Member Author

alduzy commented Aug 1, 2024

@kkafar I added a brief explanation to the description

@alduzy alduzy requested a review from WoLewicki August 5, 2024 09:05
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.

Okay, so the onPrepareOptionsMenu method is called for every screen on the stack.

Hypothesis: it seems that Android looks for closest menu in view hierarchy to update, hence if a screen does not have a header we try to update our sibling's header.

Usually this works fine because we unmount the screen below on the stack. When transparent stack presentation is in use we try to update the sibling's toolbar with transparent screen's null header config, thus effectively clearing it, leading to the bug.

The logic fix is ok, however we need to tune it up a bit. See below.

Good job overall!

@alduzy alduzy requested a review from kkafar August 6, 2024 09:15
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.

I think we're good now!

@alduzy alduzy merged commit bfd82bd into main Aug 6, 2024
4 checks passed
@alduzy alduzy deleted the @alduzy/android-transparent-modal-searchbar-fix branch August 6, 2024 09:41
ja1ns pushed a commit to WiseOwlTech/react-native-screens that referenced this pull request Oct 9, 2024
…oftware-mansion#2274)

## Description

This PR fixes disappearing search icon of the previous screen when
navigating to a transparent modal with hidden header.

When navigating to a screen with `presentation: "transparentModal"` and
`headerShown: false` the toolbar menu was
unnecessarily updated with new screen's options. The update caused the
search icon of the previous screen (still visible in the background) to
disappear.

Fixes software-mansion#2271 .

## Changes

- added `Test2271.tsx` repro
- updating the toolbar menu conditionally

## Screenshots / GIFs

### Before


https://github.com/user-attachments/assets/390f054b-b003-4b7f-b6f5-9aa9fd936dca

### After


https://github.com/user-attachments/assets/cb1fc795-c7a3-4514-9bb5-b7e1995d0b90

## Test code and steps to reproduce

- use `Test2271.tsx` for repro

## Checklist

- [x] Included code example that can be used to test this change
- [x] Ensured that CI passes
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.

HeaderSearchBar Android hides on navigation
2 participants