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): Change elements visibility on search bar open #1903

Merged
merged 1 commit into from
Sep 30, 2023

Conversation

tboba
Copy link
Member

@tboba tboba commented Sep 27, 2023

Description

Currently, when user opens the search bar all of the subviews on the toolbar are being pushed to the left.
Instead, we want to hide them or even remove them so that they won't be visible during the layout.
This PR fixes that problem by secretly hiding the toolbar elements, changing their visibility to GONE.

Fixes #1450.

Changes

  • Added a fix that is being controlled by handleOpen and handleClose methods in SearchBarView.

Screenshots / GIFs

Before

Before.mov

After

After.mov

Test code and steps to reproduce

In our example app open SearchBar.tsx and add headerRight: () => <Button title="Test"/> to the navigation.setOptions({declaration. Then launch the app and openSearch bar` example.

Checklist

  • Ensured that CI passes

@tboba tboba requested a review from kkafar September 27, 2023 15:52
@tboba tboba self-assigned this Sep 27, 2023
@tboba tboba mentioned this pull request Sep 27, 2023
1 task
@@ -110,10 +114,12 @@ class SearchBarView(reactContext: ReactContext?) : ReactViewGroup(reactContext)

private fun handleClose() {
sendEvent(SearchBarCloseEvent(surfaceId, id))
setToolbarElementsVisibility(VISIBLE)
Copy link
Member

Choose a reason for hiding this comment

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

Is there a possibility that this won't be fired, for example is we navigated when the search bar was open?

Copy link
Member Author

@tboba tboba Sep 29, 2023

Choose a reason for hiding this comment

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

@WoLewicki I thought about that already and I'm unable to reproduce the scenario where the user comes back from the search bar and in the same action comes to the previous screen. Is it even possible? 🤔

Screen.Recording.2023-09-29.at.13.21.50.mov

To test this I've changed the logic of handleClose to change the visibility of elements to INVISIBLE - that's why the element on the current screen hides.

Copy link
Member Author

Choose a reason for hiding this comment

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

So, I figured out how to do that (I'm calling navigation.navigate('Main') on onClose) and it's doing fine!

Screen.Recording.2023-09-29.at.13.53.02.mov

Copy link
Member

Choose a reason for hiding this comment

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

I think a better example would be to navigate forward and see what happens when you go back.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean navigation forward without opening the search bar? If so, then nothing would happen - state of the header subviews is only being changed on open and close searchBar events. If you mean that I should navigate forward, open the search bar and try to close it with trying to go back with back button, then (as seen above):

  1. The keyboard will close,
  2. The search bar will close,
  3. User will return to previous screen.

So it shouldn't hide, as it's not possible to return to the previous screen without closing the search bar, I guess.

Copy link
Member Author

Choose a reason for hiding this comment

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

@WoLewicki So I've checked the scenario that you've suggested and looks like everything still works - I can't manage to have search bar closed when I'm going to the next screen and coming to the previous one.

8mb.video-bqT-PgqBQjkb.mp4

I'm still thinking if changing the visibility of the element could still break at some point. Do you think we should correct the change just to make sure that we will avoid side-effects?

Copy link
Member

Choose a reason for hiding this comment

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

I think it would be some weird edge case and we can leave it as it is for now, and if the issues arise in the future, we will fix it then.

Copy link
Member

@WoLewicki WoLewicki left a comment

Choose a reason for hiding this comment

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

I left one comment, please answer it. Other than that, LGTM 🚀

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.

Hey, GJ overall.
Left single comment.

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.

🟢

@tboba tboba merged commit 7585306 into main Sep 30, 2023
4 checks passed
@tboba tboba deleted the @tboba/hide-toolbar-elements-on-search-bar-open branch September 30, 2023 12:08
renovate bot added a commit to valora-inc/wallet that referenced this pull request Nov 2, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[react-native-screens](https://togithub.com/software-mansion/react-native-screens)
| [`^3.25.0` ->
`^3.26.0`](https://renovatebot.com/diffs/npm/react-native-screens/3.25.0/3.26.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/react-native-screens/3.26.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/react-native-screens/3.26.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/react-native-screens/3.25.0/3.26.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/react-native-screens/3.25.0/3.26.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>software-mansion/react-native-screens
(react-native-screens)</summary>

###
[`v3.26.0`](https://togithub.com/software-mansion/react-native-screens/releases/tag/3.26.0)

[Compare
Source](https://togithub.com/software-mansion/react-native-screens/compare/3.25.0...3.26.0)

Minor release adding new useAnimatedHeaderHeight and
useReanimatedHeaderHeight hooks, providing fixes for search bar and
introducing internal changes. *Please note that new hooks introduced in
this release are fully functional on Paper, on Fabric there are few edge
cases we are still working on*.

#### What's Changed

#### 🐛 Bug fixes

- Change implementation of `headerConfig` prop on Android by
[@&#8203;tboba](https://togithub.com/tboba) in
[software-mansion/react-native-screens#1883
- Change elements visibility on search bar open by
[@&#8203;tboba](https://togithub.com/tboba) in
[software-mansion/react-native-screens#1903
- Fix positioning of large header and search bar by
[@&#8203;tboba](https://togithub.com/tboba) in
[software-mansion/react-native-screens#1895
- Change implementation of calculating status bar, refactor methods used
on header height change by [@&#8203;tboba](https://togithub.com/tboba)
in
[software-mansion/react-native-screens#1917
- Fix calculating header height when changing status/action bar
visibility by [@&#8203;tboba](https://togithub.com/tboba) in
[software-mansion/react-native-screens#1922
- Allow Reanimated Screen to check large header by
[@&#8203;tboba](https://togithub.com/tboba) in
[software-mansion/react-native-screens#1915
- Fix issue when emptying nav stack on Windows by
[@&#8203;chrisglein](https://togithub.com/chrisglein) in
[software-mansion/react-native-screens#1890
- Update podspec to use install_modules_dependencies by
[@&#8203;cipolleschi](https://togithub.com/cipolleschi) in
[software-mansion/react-native-screens#1920
- Remove MaxPerm args from JVM invocation by
[@&#8203;kkafar](https://togithub.com/kkafar) in
[software-mansion/react-native-screens#1888

#### 👍 Improvements

- Calculate values of useHeaderHeight natively by
[@&#8203;tboba](https://togithub.com/tboba) in
[software-mansion/react-native-screens#1802
- Allow for different fragment types inside ScreenContainer by
[@&#8203;kkafar](https://togithub.com/kkafar) in
[software-mansion/react-native-screens#1887
- Add focused states on page transitions by
[@&#8203;tboba](https://togithub.com/tboba) in
[software-mansion/react-native-screens#1894

#### 🔢 Miscellaneous

- **Create FUNDING.yml by
[@&#8203;aleqsio](https://togithub.com/aleqsio) in
[software-mansion/react-native-screens#1886
- Migrate from deprecated `RCTEventEmitter` by
[@&#8203;kkafar](https://togithub.com/kkafar) in
[software-mansion/react-native-screens#1867
- Use `require` syntax for resolution of all native components by
[@&#8203;kkafar](https://togithub.com/kkafar) in
[software-mansion/react-native-screens#1909
- Run Android e2e with JDK 17 by
[@&#8203;kkafar](https://togithub.com/kkafar) in
[software-mansion/react-native-screens#1892
- Put timelimit on execution of each workflow by
[@&#8203;kkafar](https://togithub.com/kkafar) in
[software-mansion/react-native-screens#1893
- Trigger e2e tests on JS-only changes by
[@&#8203;kkafar](https://togithub.com/kkafar) in
[software-mansion/react-native-screens#1910
- Update deprecated expo install instructions to `npx expo install` by
[@&#8203;GabrieldosSantosOliveira](https://togithub.com/GabrieldosSantosOliveira)
in
[software-mansion/react-native-screens#1899
- Bump activesupport from 6.1.7.3 to 7.0.7.2 in /TestsExample by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[software-mansion/react-native-screens#1877
- Update deps & RN in example apps after release by
[@&#8203;kkafar](https://togithub.com/kkafar) in
[software-mansion/react-native-screens#1878
- Migrate `Example` app & e2e tests to RN 0.72.4 by
[@&#8203;kkafar](https://togithub.com/kkafar) in
[software-mansion/react-native-screens#1880
- Bump library deps to recent versions (including RN) by
[@&#8203;kkafar](https://togithub.com/kkafar) in
[software-mansion/react-native-screens#1881
- Bump library native Android deps & config by
[@&#8203;kkafar](https://togithub.com/kkafar) in
[software-mansion/react-native-screens#1891

#### New Contributors

- [@&#8203;chrisglein](https://togithub.com/chrisglein) made their first
contribution in
[software-mansion/react-native-screens#1890
-
[@&#8203;GabrieldosSantosOliveira](https://togithub.com/GabrieldosSantosOliveira)
made their first contribution in
[software-mansion/react-native-screens#1899
- [@&#8203;cipolleschi](https://togithub.com/cipolleschi) made their
first contribution in
[software-mansion/react-native-screens#1920

**Full Changelog**:
software-mansion/react-native-screens@3.25.0...3.26.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 5pm,every weekend" in timezone
America/Los_Angeles, Automerge - "after 5pm,every weekend" in timezone
America/Los_Angeles.

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/valora-inc/wallet).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xOS4yIiwidXBkYXRlZEluVmVyIjoiMzcuMTkuMiIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: valora-bot <valorabot@valoraapp.com>
Co-authored-by: Silas Boyd-Wickizer <silasbw@gmail.com>
Co-authored-by: Silas Boyd-Wickizer <silas@valora.xyz>
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.

Search bar on Android incorrectly adjusts other header elements when open
3 participants