fix(components-native): Form respect safe area spacing#3078
Conversation
Deploying atlantis with
|
| Latest commit: |
189ac41
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://51be801f.atlantis.pages.dev |
| Branch Preview URL: | https://job-159045-fixoverlap.atlantis.pages.dev |
3d157a4 to
89714a3
Compare
89714a3 to
189ac41
Compare
There was a problem hiding this comment.
Pull request overview
Adjusts the native Form layout to respect bottom safe-area insets more consistently, simplifying prior edge-to-edge spacing behavior and aligning action/inline save-button spacing with safe areas.
Changes:
- Wraps
FormBodycontent in a bottom-onlySafeAreaView(safe-area-context) instead of rendering a separate padding view. - Removes edge-to-edge-specific conditional margin logic from
Form.tsxand simplifies the inline save button bottom spacing condition. - Updates safe-area rendering expectations in
Formtests whensaveButtonOffsetis provided.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| packages/components-native/src/Form/components/FormBody/FormBody.tsx | Replaces container + conditional safe-area padding view with a bottom SafeAreaView; adjusts children typing. |
| packages/components-native/src/Form/Form.tsx | Removes edgeToEdgeEnabled dependency and simplifies inline save-button bottom margin condition. |
| packages/components-native/src/Form/Form.test.tsx | Updates safe-area rendering test to expect safe area even when saveButtonOffset is provided. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export function useBottomPadding(): number { | ||
| const { insets } = useScreenInformation(); | ||
| const extraBottomSpace = insets.bottom - tokens["space-base"]; | ||
|
|
||
| return extraBottomSpace >= 0 ? extraBottomSpace : 0; | ||
| return 0; | ||
| } |
There was a problem hiding this comment.
useBottomPadding() now returns a constant 0, but it’s still used by Form to compute keyboard offsets and inline save-button spacing. This effectively disables any safe-area inset adjustment and can change behavior on devices with non-zero bottom insets. Consider either (a) re-implementing this using safe-area insets (e.g., via useSafeAreaInsets() / useScreenInformation().insets.bottom), or (b) removing the hook and simplifying the dependent calculations so they don’t rely on a dead value.
| styles.fixedSaveButton, | ||
| (edgeToEdgeEnabled || Platform.OS !== "android") && { | ||
| marginBottom: paddingBottom, | ||
| }, | ||
| paddingBottom > 0 && { marginBottom: paddingBottom }, | ||
| ]} |
There was a problem hiding this comment.
This marginBottom branch is currently unreachable because paddingBottom comes from useBottomPadding(), which now always returns 0. If the intent is to keep inline save-button spacing aligned with the bottom safe area, paddingBottom needs to be sourced from safe-area insets (or the entire paddingBottom plumbing should be removed if SafeAreaView already guarantees the desired spacing).
|
|
||
| it("does NOT render a safe area when there's a saveButtonOffset is provided", () => { | ||
| const { queryByTestId } = render( | ||
| it("does render a safe area when there's a saveButtonOffset is provided", () => { |
There was a problem hiding this comment.
Test description is grammatically incorrect; consider rephrasing for clarity (e.g., remove the extra “is”).
| it("does render a safe area when there's a saveButtonOffset is provided", () => { | |
| it("does render a safe area when there's a saveButtonOffset provided", () => { |
| interface FormBodyProps extends FormActionBarProps { | ||
| readonly children: ReactElement; | ||
| readonly children: ReactNode; | ||
| readonly shouldRenderActionBar?: boolean; | ||
| readonly saveButtonOffset?: number; | ||
| } |
There was a problem hiding this comment.
saveButtonOffset is still declared on FormBodyProps, but FormBody no longer reads it (it isn’t destructured/used). This makes the prop misleading and easy to assume it still influences safe-area behavior. Either remove saveButtonOffset from FormBodyProps (and stop passing it from the parent), or re-introduce behavior that actually depends on it.
Summary
Before
buttonOverlapBefore.mp4
After
buttonOverlapAfter.mp4
Testing