Skip to content

Conversation

@kligarski
Copy link
Contributor

@kligarski kligarski commented Sep 25, 2025

Description

Ensures consistent default behavior for autoCapitalize prop in SearchBar.

This will require changes in react-navigation's docs (https://github.com/software-mansion/react-native-screens-labs/issues/470).

Before

Prior to this PR, changing autoCapitalize to none on Fabric required changing the value to something else and then changing it back to none as none was the default value in Fabric spec file for SearchBar (controller would not get the updated value and used UIKit default - sentences).

autoCapitalize_before_iOS_Fabric.mov

After

In this PR, bug described in section above is fixed. Consistent behavior across platforms and architectures is ensured.

autoCapitalize_after_iOS_Fabric.mov

systemDefault option allows correct handling of different search input default behaviors on Android and iOS:

  • on Android, default behavior is the same as none,
  • on iOS, default behavior is the same as sentences.

Changes

  • add systemDefault to autoCapitalize in SearchBar
  • handle systemDefault on both platforms and both architectures
  • parse JS autoCapitalize prop by mapping undefined to systemDefault to ensure consistent behavior between Paper and Fabric: on Paper, setter does not run if we pass undefined as the value of the prop whereas on Fabric, default value of systemDefault is used.

Test code and steps to reproduce

Run Test758 with commented-out search bar options. Add autoCapitalize: 'none' and verify correct behavior.

Checklist


// This function is necessary for legacy architecture (Paper) to ensure
// consistent behavior for props with `systemDefault` option.
function parseUndefinedPropsToSystemDefault(
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I'd say something like decorateAutocapitalizeWithSystemDefaultIfNeeded would sound better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assumed that there might be more props that will require this kind of handling (but at the moment I'm not sure if there will be more) and wanted to use only one function for all of them so that it's easier to delete it in the future when we drop support for legacy architecture.

Also, isn't decorate a little bit too much for simple if (value === undefined) return "systemDefault"?

I'm open for suggestions here.

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.

Good catch. The code looks sensible. Thank you.

@kligarski kligarski force-pushed the @kligarski/fix-search-bar-auto-capitalize-default branch from e79513a to ad380d1 Compare September 30, 2025 06:32
@kligarski kligarski merged commit 7e0dc77 into main Sep 30, 2025
9 checks passed
@kligarski kligarski deleted the @kligarski/fix-search-bar-auto-capitalize-default branch September 30, 2025 06:33
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.

5 participants