-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix next button isn't aligned at bottom in switch to expensify reason form page #47957
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] |
// Minus the height of the text component | ||
textStyle.lineHeight - | ||
headerTitleHeight - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use dynamic values for these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
<FormElement | |
key={formID} | |
ref={formContentRef} | |
style={[style, safeAreaPaddingBottomStyle.paddingBottom ? safeAreaPaddingBottomStyle : styles.pb5]} |
and the last 1 is from useSafePaddingBottomStyle
.
App/src/components/FormAlertWithSubmitButton.tsx
Lines 99 to 100 in 117b961
<FormAlertWrapper | |
containerStyles={[styles.justifyContentEnd, safePaddingBottomStyle, containerStyles]} |
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
function getSafeAreaPadding(insets?: EdgeInsets, insetsPercentage: number = variables.safeInsertPercentage): SafeAreaPadding { | |
return { | |
paddingTop: insets?.top ?? 0, | |
paddingBottom: (insets?.bottom ?? 0) * insetsPercentage, |
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and tests well 🚀
✋ 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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.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