From 0a6fb8fbb7c746ff04c8aa72e5defd768ec708cc Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Mon, 17 Mar 2025 23:56:04 +0100 Subject: [PATCH 1/2] fix: don't apply legacy bottom safe area if `addBottomSafeAreaPadding` is not set --- src/components/Form/FormWrapper.tsx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/components/Form/FormWrapper.tsx b/src/components/Form/FormWrapper.tsx index 671c0c708f0a9..9620beca033b2 100644 --- a/src/components/Form/FormWrapper.tsx +++ b/src/components/Form/FormWrapper.tsx @@ -68,8 +68,8 @@ function FormWrapper({ isSubmitDisabled = false, isLoading = false, shouldScrollToEnd = false, - addBottomSafeAreaPadding = true, - shouldSubmitButtonStickToBottom = false, + addBottomSafeAreaPadding, + shouldSubmitButtonStickToBottom: shouldSubmitButtonStickToBottomProp, }: FormWrapperProps) { const styles = useThemeStyles(); const formRef = useRef(null); @@ -110,7 +110,18 @@ function FormWrapper({ focusInput?.focus?.(); }, [errors, formState?.errorFields, inputRefs]); - const {paddingBottom} = useSafeAreaPaddings(true); + // If either of `addBottomSafeAreaPadding` or `shouldSubmitButtonStickToBottom` is explicitly set, + // we expect that the user wants to use the new edge-to-edge bottom safe area padding handling. + // In this case, we want to get and apply the padding unconditionnally. + const enableEdgeToEdgeBottomSafeAreaPadding = addBottomSafeAreaPadding === undefined && shouldSubmitButtonStickToBottomProp === undefined; + const shouldSubmitButtonStickToBottom = shouldSubmitButtonStickToBottomProp ?? false; + const {paddingBottom} = useSafeAreaPaddings(enableEdgeToEdgeBottomSafeAreaPadding); + + // Same as above, if `addBottomSafeAreaPadding` is explicitly set true, we default to the new edge-to-edge bottom safe area padding handling. + // If the paddingBottom is 0, it has already been applied to a parent component and we don't want to apply the padding again. + const isLegacyBottomSafeAreaPaddingAlreadyApplied = paddingBottom === 0; + const shouldApplyBottomSafeAreaPadding = addBottomSafeAreaPadding ?? !isLegacyBottomSafeAreaPaddingAlreadyApplied; + const SubmitButton = useMemo( () => isSubmitButtonVisible && ( @@ -180,7 +191,6 @@ function FormWrapper({ { if (!shouldScrollToEnd) { @@ -220,7 +230,7 @@ function FormWrapper({ style={[styles.w100, styles.flex1]} contentContainerStyle={styles.flexGrow1} keyboardShouldPersistTaps="handled" - addBottomSafeAreaPadding={addBottomSafeAreaPadding} + addBottomSafeAreaPadding={shouldApplyBottomSafeAreaPadding} ref={formRef} > {scrollViewContent()} @@ -230,7 +240,7 @@ function FormWrapper({ style={[styles.w100, styles.flex1]} contentContainerStyle={styles.flexGrow1} keyboardShouldPersistTaps="handled" - addBottomSafeAreaPadding={addBottomSafeAreaPadding} + addBottomSafeAreaPadding={shouldApplyBottomSafeAreaPadding} ref={formRef} > {scrollViewContent()} From b2fd9de3dc68c1da58dffeda68e62433f965e441 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 18 Mar 2025 00:52:00 +0100 Subject: [PATCH 2/2] fix: incorrect condition --- src/components/Form/FormWrapper.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Form/FormWrapper.tsx b/src/components/Form/FormWrapper.tsx index 9620beca033b2..c4544ae619076 100644 --- a/src/components/Form/FormWrapper.tsx +++ b/src/components/Form/FormWrapper.tsx @@ -113,7 +113,7 @@ function FormWrapper({ // If either of `addBottomSafeAreaPadding` or `shouldSubmitButtonStickToBottom` is explicitly set, // we expect that the user wants to use the new edge-to-edge bottom safe area padding handling. // In this case, we want to get and apply the padding unconditionnally. - const enableEdgeToEdgeBottomSafeAreaPadding = addBottomSafeAreaPadding === undefined && shouldSubmitButtonStickToBottomProp === undefined; + const enableEdgeToEdgeBottomSafeAreaPadding = addBottomSafeAreaPadding !== undefined || shouldSubmitButtonStickToBottomProp !== undefined; const shouldSubmitButtonStickToBottom = shouldSubmitButtonStickToBottomProp ?? false; const {paddingBottom} = useSafeAreaPaddings(enableEdgeToEdgeBottomSafeAreaPadding);