Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion guides/GUIDE_FOR_LIBRARY_AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ To render a search bar use `ScreenStackHeaderSearchBarView` with `<SearchBar>` 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.
Expand Down
9 changes: 6 additions & 3 deletions ios/RNSSearchBar.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/fabric/SearchBarNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export interface NativeProps extends ViewProps {
placeholder?: string;
placement?: WithDefault<SearchBarPlacement, 'automatic'>;
allowToolbarIntegration?: WithDefault<boolean, true>;
obscureBackground?: boolean;
hideNavigationBar?: boolean;
obscureBackground?: WithDefault<boolean, false>;
hideNavigationBar?: WithDefault<boolean, true>;
cancelButtonText?: string;
// TODO: implement these on iOS
barTintColor?: ColorValue;
Expand Down
Loading