Skip to content

Commit e3c179a

Browse files
authored
feat: rounded prop for KeyboardEffects (#1578)
## 📜 Description Added `rounded` property for `KeyboardEffects` component. ## 💡 Motivation and Context These changes were requested in #1567 In fact it makes sense - if you want to render a solid background so that messages are not visible in corners, i. e. create effect of shrinking view - why not? So I made it cusomizable. Few important findings: - since we now control rounding via new prop I reverted changes where `translucent` property by default make keyboard not-rounded; - I intentionally chose `rounded` name to be consistent with `translucent` (not `isRounded` etc.) Closes #1567 ## 📢 Changelog <!-- High level overview of important changes --> <!-- For example: fixed status bar manipulation; added new types declarations; --> <!-- If your changes don't affect one of platform/language below - then remove this platform/language --> ### Docs - added documentation for new `rounded` property; ### JS - `translucent` doesn't disable rounding by default; - added new `rounded` property. ## 🤔 How Has This Been Tested? Tested manually in example app. ## 📸 Screenshots (if appropriate): |Before|After| |-------|-----| |<img width="1206" height="2622" alt="image" src="https://github.com/user-attachments/assets/5324c943-be74-4ee3-ba52-5c3db826d9ce" />|<img width="1206" height="2622" alt="image" src="https://github.com/user-attachments/assets/49caf660-bda2-4a82-848f-10d91c4f6586" />| ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
1 parent 9e63b74 commit e3c179a

5 files changed

Lines changed: 33 additions & 5 deletions

File tree

  • FabricExample/src/screens/Examples/AIKeyboard
  • docs
    • docs/api/components/keyboard-effects
    • versioned_docs/version-1.22.0/api/components/keyboard-effects
  • example/src/screens/Examples/AIKeyboard
  • src/components/KeyboardEffects

FabricExample/src/screens/Examples/AIKeyboard/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const AIKeyboard = () => (
2222
<SafeAreaView style={styles.hero}>
2323
<Text style={styles.title}>Describe an image or add a suggestion.</Text>
2424
</SafeAreaView>
25-
<KeyboardEffects translucent>
25+
<KeyboardEffects translucent rounded={false}>
2626
<KeyboardGradient />
2727
</KeyboardEffects>
2828
<KeyboardStickyView offset={{ opened: 16 }} style={styles.sticky}>

docs/docs/api/components/keyboard-effects/index.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,13 @@ A boolean prop indicating whether the keyboard backdrop should be translucent. W
6161
:::note Multiple instances
6262
Multiple mounted `KeyboardEffects` instances share a single native keyboard state, reconciled the same way React Native's `StatusBar` reconciles multiple instances: each instance's `translucent` value sits on a shared stack, and whichever instance was mounted (or updated) most recently wins. When that instance unmounts, the keyboard falls back to the value of the next-most-recently-mounted instance still on screen — not straight to opaque.
6363
:::
64+
65+
### `rounded`
66+
67+
A boolean prop indicating whether the effect view should match the keyboard's rounded top corners. When `true` (default), content behind an opaque keyboard is clipped to those corners. Set it to `false` to ignore the automatic corner rounding and fully cover the keyboard bounds — useful when a scrollable surface behind the keyboard should remain completely occluded.
68+
69+
```tsx
70+
<KeyboardEffects rounded={false}>
71+
<View style={{ flex: 1, backgroundColor: "purple" }} />
72+
</KeyboardEffects>
73+
```

docs/versioned_docs/version-1.22.0/api/components/keyboard-effects/index.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,13 @@ A boolean prop indicating whether the keyboard backdrop should be translucent. W
6161
:::note Multiple instances
6262
Multiple mounted `KeyboardEffects` instances share a single native keyboard state, reconciled the same way React Native's `StatusBar` reconciles multiple instances: each instance's `translucent` value sits on a shared stack, and whichever instance was mounted (or updated) most recently wins. When that instance unmounts, the keyboard falls back to the value of the next-most-recently-mounted instance still on screen — not straight to opaque.
6363
:::
64+
65+
### `rounded`
66+
67+
A boolean prop indicating whether the effect view should match the keyboard's rounded top corners. When `true` (default), content behind an opaque keyboard is clipped to those corners. Set it to `false` to ignore the automatic corner rounding and fully cover the keyboard bounds — useful when a scrollable surface behind the keyboard should remain completely occluded.
68+
69+
```tsx
70+
<KeyboardEffects rounded={false}>
71+
<View style={{ flex: 1, backgroundColor: "purple" }} />
72+
</KeyboardEffects>
73+
```

example/src/screens/Examples/AIKeyboard/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const AIKeyboard = () => (
2222
<SafeAreaView style={styles.hero}>
2323
<Text style={styles.title}>Describe an image or add a suggestion.</Text>
2424
</SafeAreaView>
25-
<KeyboardEffects translucent>
25+
<KeyboardEffects translucent rounded={false}>
2626
<KeyboardGradient />
2727
</KeyboardEffects>
2828
<KeyboardStickyView offset={{ opened: 16 }} style={styles.sticky}>

src/components/KeyboardEffects/index.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ export type KeyboardEffectsProps = {
4949
* @default false
5050
*/
5151
translucent?: boolean;
52+
/**
53+
* Whether the effect view should match the keyboard's rounded top corners.
54+
*
55+
* Set to `false` when the effect should fully cover the keyboard bounds.
56+
*
57+
* @default true
58+
*/
59+
rounded?: boolean;
5260
} & KeyboardStickyViewProps;
5361

5462
/**
@@ -70,16 +78,16 @@ export type KeyboardEffectsProps = {
7078
const KeyboardEffects = forwardRef<
7179
View,
7280
React.PropsWithChildren<KeyboardEffectsProps>
73-
>(({ translucent, children, ...props }, ref) => {
81+
>(({ translucent, rounded = true, children, ...props }, ref) => {
7482
const stackEntry = useRef<TranslucentStackEntry>({
7583
translucent: Boolean(translucent),
7684
}).current;
7785
const containerStyle = useMemo(
7886
() => [
7987
styles.container,
80-
KEYBOARD_HAS_ROUNDED_CORNERS && !translucent && styles.rounded,
88+
KEYBOARD_HAS_ROUNDED_CORNERS && rounded && styles.rounded,
8189
],
82-
[translucent],
90+
[rounded],
8391
);
8492

8593
useEffect(() => {

0 commit comments

Comments
 (0)