Fix next button isn't aligned at bottom in switch to expensify reason form page#47957
Conversation
|
@rayane-djouah Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
| safePaddingBottomStyleValue - | ||
| // Minus the height of the text component | ||
| textStyle.lineHeight - | ||
| headerTitleHeight - |
There was a problem hiding this comment.
One of the reasons the form errors overlaps is because the height of the title here is only a one-line height, but the title could be more than 1 line.
The extra margin value (baseResponseInputContainerStyle.marginTop * 2) calculation below and the vertical margins (40) should be enough to cover the form error, but the form error (Please fix the errors in the form before continuing.) could be more than 1 line too, so I add an extra 20 as the safe value.
Reviewer Checklist
Screenshots/Videos |
| // Minus the vertical margins around the form button | ||
| 40, | ||
| 40 - | ||
| // Minus the extra height for the form error text | ||
| 20, |
There was a problem hiding this comment.
Can we use dynamic values for these?
|
Bug 1: mWeb Safari only - Empty space below the "Next" button when we open the page, and the button does not keep its position above the keyboard Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-08-30.at.22.50.16.mp4 |
| // Device safe area top and bottom insets. | ||
| // When the keyboard is shown, the bottom inset doesn't affect the height, so we take it out from the calculation. | ||
| const {top: safeAreaInsetsTop, bottom: safeAreaInsetsBottom} = useSafeAreaInsets(); | ||
| const safeAreaInsetsBottomValue = !keyboardHeight ? safeAreaInsetsBottom : 0; |
There was a problem hiding this comment.
useSafeAreaInsets doesn't affect the height when the keyboard is shown.
| const formPaddingBottomValue = formPaddingBottom || styles.pb5.paddingBottom; | ||
| // Extra bottom padding in FormAlertWithSubmitButton | ||
| const safePaddingBottomStyle = useSafePaddingBottomStyle(); | ||
| const safePaddingBottomStyleValue = 'paddingBottom' in safePaddingBottomStyle ? (safePaddingBottomStyle.paddingBottom as number) : 0; |
There was a problem hiding this comment.
For the recent fix, I add another inset from useStyledSafeAreaInsets to use in the calculation.
The form currently has 3 bottom spacings. 1 from safe area insets (ScreenWrapper), 1 from styled safe area insets,
App/src/components/Form/FormWrapper.tsx
Lines 107 to 110 in 117b961
and the last 1 is from useSafePaddingBottomStyle.
App/src/components/FormAlertWithSubmitButton.tsx
Lines 99 to 100 in 117b961
useSafeAreaInsets is added in ScreenWrapper so it won't overlap with this.

The other 2 just add additional spacing in 2 different places and 2 different values.
FormAlertWithSubmitButton which uses useSafePaddingBottomStyle adds 20px while FormWrapper uses useStyledSafeAreaInsets with the same value as useSafeAreaInsets but multiplied by 0.7 and fallback to 20px if the bottom inset is not available (for Android).
Lines 329 to 332 in 117b961
| // Minus the height above the button for the form error text, accounting for 2 lines max. | ||
| variables.lineHeightNormal * 2 - | ||
| // Minus the margin between the button and the form error text | ||
| styles.mb3.marginBottom, |
There was a problem hiding this comment.
Instead of using 40 to create the effect of both the margin top and bottom, I changed it to use the error text line height multiplied by 2 to account for 2 lines of error and also a margin-bottom that exists between the error text and the button.
The value now becomes (16-21 (scale depends on font size) * 2) + 12 = ~44-54
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/roryabraham in version: 9.0.29-0 🚀
|
|
🚀 Deployed to production by https://github.com/roryabraham in version: 9.0.29-12 🚀
|












Details
The page has a max height but it's set smaller than it should be, so the button isn't aligned at the bottom. This PR fix it.
Fixed Issues
$ #47280
PROPOSAL: #47280 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
android.mp4
Android: mWeb Chrome
android.mweb.mp4
iOS: Native
ios.mp4
iOS: mWeb Safari
ios.mweb.mp4
MacOS: Chrome / Safari
web.mp4
MacOS: Desktop
desktop.mp4