From c64f7dcfc04eec0c365fd7b6ddddfa9aef73f5d0 Mon Sep 17 00:00:00 2001 From: Krzysztof Ligarski Date: Fri, 5 Sep 2025 10:30:50 +0200 Subject: [PATCH 1/2] ensure consistent defaults for obscureBackground and hideNavigationBar --- .../react/viewmanagers/RNSSearchBarManagerDelegate.java | 2 +- ios/RNSSearchBar.mm | 9 ++++++--- src/fabric/SearchBarNativeComponent.ts | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSSearchBarManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSSearchBarManagerDelegate.java index 948d3402d8..ea0919ea78 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSSearchBarManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSSearchBarManagerDelegate.java @@ -43,7 +43,7 @@ public void setProperty(T view, String propName, @Nullable Object value) { mViewManager.setObscureBackground(view, value == null ? false : (boolean) value); break; case "hideNavigationBar": - mViewManager.setHideNavigationBar(view, value == null ? false : (boolean) value); + mViewManager.setHideNavigationBar(view, value == null ? true : (boolean) value); break; case "cancelButtonText": mViewManager.setCancelButtonText(view, value == null ? null : (String) value); diff --git a/ios/RNSSearchBar.mm b/ios/RNSSearchBar.mm index 6e6ce17e9b..b64e7f0bd3 100644 --- a/ios/RNSSearchBar.mm +++ b/ios/RNSSearchBar.mm @@ -66,6 +66,11 @@ - (void)initCommonProps #endif _controller.searchBar.delegate = self; + + // Ensure consistent default values on both architectures + _controller.hidesNavigationBarDuringPresentation = YES; + _controller.obscuresBackgroundDuringPresentation = NO; + _hideWhenScrolling = YES; _placement = RNSSearchBarPlacementAutomatic; @@ -149,9 +154,7 @@ - (void)emitOnChangeTextEventWithText:(NSString *)text - (void)setObscureBackground:(BOOL)obscureBackground { - if (@available(iOS 9.1, *)) { - [_controller setObscuresBackgroundDuringPresentation:obscureBackground]; - } + [_controller setObscuresBackgroundDuringPresentation:obscureBackground]; } - (void)setHideNavigationBar:(BOOL)hideNavigationBar diff --git a/src/fabric/SearchBarNativeComponent.ts b/src/fabric/SearchBarNativeComponent.ts index 6794183c3e..0aa51b0696 100644 --- a/src/fabric/SearchBarNativeComponent.ts +++ b/src/fabric/SearchBarNativeComponent.ts @@ -40,8 +40,8 @@ export interface NativeProps extends ViewProps { placeholder?: string; placement?: WithDefault; allowToolbarIntegration?: WithDefault; - obscureBackground?: boolean; - hideNavigationBar?: boolean; + obscureBackground?: WithDefault; + hideNavigationBar?: WithDefault; cancelButtonText?: string; // TODO: implement these on iOS barTintColor?: ColorValue; From 5fb3fe186a54d0bf1c74170b89673b4176e4196f Mon Sep 17 00:00:00 2001 From: Krzysztof Ligarski Date: Fri, 5 Sep 2025 11:24:55 +0200 Subject: [PATCH 2/2] update guide for library authors --- guides/GUIDE_FOR_LIBRARY_AUTHORS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/GUIDE_FOR_LIBRARY_AUTHORS.md b/guides/GUIDE_FOR_LIBRARY_AUTHORS.md index 4904a12950..d7b432ef89 100644 --- a/guides/GUIDE_FOR_LIBRARY_AUTHORS.md +++ b/guides/GUIDE_FOR_LIBRARY_AUTHORS.md @@ -461,7 +461,7 @@ To render a search bar use `ScreenStackHeaderSearchBarView` with `` c - `hideNavigationBar` - Boolean indicating whether to hide the navigation bar during searching. Defaults to `true`. (iOS only) - `hideWhenScrolling` - Boolean indicating whether to hide the search bar when scrolling. Defaults to `true`. (iOS only) - `inputType` - Specifies type of input and keyboard for search bar. Can be one of `'text'`, `'phone'`, `'number'`, `'email'`. Defaults to `'text'`. (Android only) -- `obscureBackground` - Boolean indicating whether to obscure the underlying content with semi-transparent overlay. Defaults to `true`. (iOS only) +- `obscureBackground` - Boolean indicating whether to obscure the underlying content with semi-transparent overlay. Defaults to `false`. (iOS only) - `onBlur` - A callback that gets called when search bar has lost focus. - `onChangeText` - A callback that gets called when the text changes. It receives the current text value of the search bar. - `onCancelButtonPress` - A callback that gets called when the cancel button is pressed.