Skip to content

Commit b8fb149

Browse files
committed
fix sheet padding
1 parent 35f7d64 commit b8fb149

File tree

2 files changed

+38
-10
lines changed

2 files changed

+38
-10
lines changed

src/components/Dialog/index.tsx

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ export function Outer({
182182
)
183183
}
184184

185+
/**
186+
* @deprecated use `Dialog.ScrollableInner` instead
187+
*/
185188
export function Inner({children, style, header}: DialogInnerProps) {
186189
const insets = useSafeAreaInsets()
187190
return (
@@ -207,6 +210,7 @@ export const ScrollableInner = React.forwardRef<ScrollView, DialogInnerProps>(
207210
) {
208211
const {nativeSnapPoint, disableDrag, setDisableDrag} = useDialogContext()
209212
const insets = useSafeAreaInsets()
213+
const [contentSize, setContentSize] = React.useState(0)
210214

211215
useEnableKeyboardController(isIOS)
212216

@@ -225,14 +229,10 @@ export const ScrollableInner = React.forwardRef<ScrollView, DialogInnerProps>(
225229
let paddingBottom = 0
226230
if (isIOS) {
227231
paddingBottom += keyboardHeight / 4
228-
if (isIOS26) {
229-
paddingBottom += tokens.space.xl
230-
} else {
231-
if (nativeSnapPoint === BottomSheetSnapPoint.Full) {
232-
paddingBottom += insets.bottom + tokens.space.md
233-
}
234-
paddingBottom = Math.max(paddingBottom, tokens.space._2xl)
232+
if (nativeSnapPoint === BottomSheetSnapPoint.Full) {
233+
paddingBottom += insets.bottom + tokens.space.md
235234
}
235+
paddingBottom = Math.max(paddingBottom, tokens.space._2xl)
236236
} else {
237237
paddingBottom += keyboardHeight
238238
if (nativeSnapPoint === BottomSheetSnapPoint.Full) {
@@ -254,11 +254,37 @@ export const ScrollableInner = React.forwardRef<ScrollView, DialogInnerProps>(
254254
}
255255
}
256256

257+
// iOS26 floaty sheets have this annoying extra safe area when sheets are 150px or more
258+
// TODO: Remove this behaviour on the native side!! I could not figure it out -sfn
259+
//
260+
// fix by using a negative margin on the scrollview when the sheet is in this zone (it's fine for large sheets)
261+
const IOS_MIN_HEIGHT_FOR_SAFEAREA = 151
262+
const IOS_MAX_HEIGHT_FOR_SAFEAREA = 400
263+
const iosAutoSafeAreaHeightAdjust = 34
264+
const shouldAttemptUndoSafeArea =
265+
isIOS26 &&
266+
contentSize > IOS_MIN_HEIGHT_FOR_SAFEAREA &&
267+
contentSize < IOS_MAX_HEIGHT_FOR_SAFEAREA
268+
const adjustedSize =
269+
contentSize -
270+
(shouldAttemptUndoSafeArea ? iosAutoSafeAreaHeightAdjust : 0)
271+
// reducing the padding obviously then makes it dip back under 150px, so we need to adjust
272+
// again to ensure a minimum height of 150
273+
const ensureMinHeight = Math.min(
274+
0,
275+
adjustedSize - IOS_MIN_HEIGHT_FOR_SAFEAREA,
276+
)
277+
const marginBottom = shouldAttemptUndoSafeArea
278+
? iosAutoSafeAreaHeightAdjust * -1 - ensureMinHeight
279+
: 0
280+
257281
return (
258282
<KeyboardAwareScrollView
283+
style={[{marginBottom}]}
284+
onContentSizeChange={(_width, height) => setContentSize(height)}
259285
contentContainerStyle={[
260286
a.pt_2xl,
261-
a.px_xl,
287+
a.px_2xl,
262288
{paddingBottom},
263289
contentContainerStyle,
264290
]}

src/components/Menu/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ export function ContainerItem({
270270
a.align_center,
271271
a.gap_sm,
272272
a.px_md,
273-
a.rounded_md,
273+
a.rounded_lg,
274+
a.curve_continuous,
274275
a.border,
275276
t.atoms.bg_contrast_25,
276277
t.atoms.border_contrast_low,
@@ -308,7 +309,8 @@ export function Group({children, style}: GroupProps) {
308309
return (
309310
<View
310311
style={[
311-
a.rounded_md,
312+
a.rounded_lg,
313+
a.curve_continuous,
312314
a.overflow_hidden,
313315
a.border,
314316
t.atoms.border_contrast_low,

0 commit comments

Comments
 (0)