Skip to content

Commit 2d2efa0

Browse files
committed
fix:65123: added forwardRef ro ScreenWraperContainer
1 parent f518cd2 commit 2d2efa0

3 files changed

Lines changed: 6 additions & 13 deletions

File tree

src/components/ScreenWrapper/ScreenWrapperContainer.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type {ForwardedRef, ReactNode} from 'react';
2-
import React, {useContext, useEffect, useMemo, useRef} from 'react';
2+
import React, {forwardRef, useContext, useEffect, useMemo, useRef} from 'react';
33
import type {StyleProp, ViewStyle} from 'react-native';
44
import {Keyboard, PanResponder, View} from 'react-native';
55
import {PickerAvoidingView} from 'react-native-picker-select';
@@ -18,9 +18,6 @@ import toggleTestToolsModal from '@userActions/TestTool';
1818
import CONST from '@src/CONST';
1919

2020
type ScreenWrapperContainerProps = React.PropsWithChildren<{
21-
/** Ref for the screen wrapper container */
22-
forwardedRef?: ForwardedRef<View>;
23-
2421
/** A unique ID to find the screen wrapper in tests */
2522
testID: string;
2623

@@ -87,7 +84,6 @@ type ScreenWrapperContainerProps = React.PropsWithChildren<{
8784
}>;
8885

8986
function ScreenWrapperContainer({
90-
forwardedRef,
9187
children,
9288
style,
9389
testID,
@@ -107,7 +103,7 @@ function ScreenWrapperContainer({
107103
includePaddingTop = true,
108104
includeSafeAreaPaddingBottom = false,
109105
isFocused = true,
110-
}: ScreenWrapperContainerProps) {
106+
}: ScreenWrapperContainerProps, ref: ForwardedRef<View>) {
111107
const {windowHeight} = useWindowDimensions(shouldUseCachedViewportHeight);
112108
const {initialHeight} = useInitialDimensions();
113109
const styles = useThemeStyles();
@@ -199,7 +195,7 @@ function ScreenWrapperContainer({
199195

200196
return (
201197
<View
202-
ref={forwardedRef}
198+
ref={ref}
203199
style={[styles.flex1, {minHeight}]}
204200
// eslint-disable-next-line react/jsx-props-no-spreading, react-compiler/react-compiler
205201
{...panResponder.panHandlers}
@@ -234,5 +230,5 @@ function ScreenWrapperContainer({
234230
}
235231
ScreenWrapperContainer.displayName = 'ScreenWrapperContainer';
236232

237-
export default React.memo(ScreenWrapperContainer);
233+
export default React.memo(forwardRef(ScreenWrapperContainer));
238234
export type {ScreenWrapperContainerProps};

src/components/ScreenWrapper/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ function ScreenWrapper(
234234
return (
235235
<FocusTrapForScreen focusTrapSettings={focusTrapSettings}>
236236
<ScreenWrapperContainer
237-
forwardedRef={ref}
237+
ref={ref}
238238
style={[styles.flex1, style]}
239239
bottomContent={bottomContent}
240240
didScreenTransitionEnd={didScreenTransitionEnd}

src/pages/workspace/WorkspaceNamePage.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import type {FormInputErrors, FormOnyxValues} from '@components/Form/types';
66
import HeaderWithBackButton from '@components/HeaderWithBackButton';
77
import ScreenWrapper from '@components/ScreenWrapper';
88
import TextInput from '@components/TextInput';
9-
import useAutoFocusInput from '@hooks/useAutoFocusInput';
109
import useLocalize from '@hooks/useLocalize';
1110
import useThemeStyles from '@hooks/useThemeStyles';
1211
import {updateGeneralSettings} from '@libs/actions/Policy/Policy';
@@ -26,8 +25,6 @@ function WorkspaceNamePage({policy}: Props) {
2625
const styles = useThemeStyles();
2726
const {translate} = useLocalize();
2827

29-
const {inputCallbackRef} = useAutoFocusInput();
30-
3128
const submit = useCallback(
3229
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.WORKSPACE_SETTINGS_FORM>) => {
3330
if (!policy || policy.isPolicyUpdating) {
@@ -94,7 +91,7 @@ function WorkspaceNamePage({policy}: Props) {
9491
accessibilityLabel={translate('workspace.common.workspaceName')}
9592
defaultValue={policy?.name}
9693
spellCheck={false}
97-
ref={inputCallbackRef}
94+
autoFocus
9895
/>
9996
</View>
10097
</FormProvider>

0 commit comments

Comments
 (0)