Skip to content

Commit b772b17

Browse files
authored
make sure to pass forward ref in KeyboardTrackingView component (#1552)
1 parent 6fc5719 commit b772b17

File tree

3 files changed

+47
-9
lines changed
  • generatedTypes/lib/components/Keyboard
  • lib/components/Keyboard/KeyboardTracking/KeyboardTrackingView

3 files changed

+47
-9
lines changed

generatedTypes/lib/components/Keyboard/KeyboardTracking/KeyboardTrackingView/index.d.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,30 @@ export declare type KeyboardTrackingViewProps = ViewProps & {
2626
children?: React.ReactChild | React.ReactChild[];
2727
style?: ViewStyle;
2828
};
29-
declare const KeyboardTrackingView: ({ children, ...others }: KeyboardTrackingViewProps) => JSX.Element;
30-
export default KeyboardTrackingView;
29+
declare const _default: React.ForwardRefExoticComponent<Pick<ViewProps & {
30+
/**
31+
* Enables tracking of the keyboard when it's dismissed interactively (false by default).
32+
* Why? When using an external keyboard (BT),
33+
* you still get the keyboard events and the view just hovers when you focus the input.
34+
* Also, if you're not using interactive style of dismissing the keyboard
35+
* (or if you don't have an input inside this view) it doesn't make sense to track it anyway.
36+
* (This is caused because of the usage of inputAccessory to be able to track the
37+
* keyboard interactive change and it introduces this bug)
38+
*/
39+
trackInteractive?: boolean | undefined;
40+
/**
41+
* Allow control safe area
42+
*/
43+
useSafeArea?: boolean | undefined;
44+
scrollToFocusedInput?: boolean | undefined;
45+
scrollBehavior?: number | undefined;
46+
revealKeyboardInteractive?: boolean | undefined;
47+
manageScrollView?: boolean | undefined;
48+
requiresSameParentToManageScrollView?: boolean | undefined;
49+
addBottomView?: boolean | undefined;
50+
allowHitsOutsideBounds?: boolean | undefined;
51+
ref?: any;
52+
children?: React.ReactChild | React.ReactChild[] | undefined;
53+
style?: ViewStyle | undefined;
54+
}, "children" | keyof ViewProps | "useSafeArea" | "trackInteractive" | "scrollToFocusedInput" | "scrollBehavior" | "revealKeyboardInteractive" | "manageScrollView" | "requiresSameParentToManageScrollView" | "addBottomView" | "allowHitsOutsideBounds"> & React.RefAttributes<unknown>>;
55+
export default _default;

generatedTypes/lib/components/Keyboard/index.d.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,20 @@ import KeyboardAccessoryView, { KeyboardAccessoryViewProps } from './KeyboardInp
55
import KeyboardUtils from './KeyboardInput/utils/KeyboardUtils';
66
export { KeyboardTrackingViewProps, KeyboardAccessoryViewProps };
77
declare const _default: {
8-
KeyboardTrackingView: ({ children, ...others }: KeyboardTrackingViewProps) => JSX.Element;
8+
KeyboardTrackingView: import("react").ForwardRefExoticComponent<Pick<import("react-native").ViewProps & {
9+
trackInteractive?: boolean | undefined;
10+
useSafeArea?: boolean | undefined;
11+
scrollToFocusedInput?: boolean | undefined;
12+
scrollBehavior?: number | undefined;
13+
revealKeyboardInteractive?: boolean | undefined;
14+
manageScrollView?: boolean | undefined;
15+
requiresSameParentToManageScrollView?: boolean | undefined;
16+
addBottomView?: boolean | undefined;
17+
allowHitsOutsideBounds?: boolean | undefined;
18+
ref?: any;
19+
children?: import("react").ReactChild | import("react").ReactChild[] | undefined;
20+
style?: import("react-native").ViewStyle | undefined;
21+
}, "children" | keyof import("react-native").ViewProps | "useSafeArea" | "trackInteractive" | "scrollToFocusedInput" | "scrollBehavior" | "revealKeyboardInteractive" | "manageScrollView" | "requiresSameParentToManageScrollView" | "addBottomView" | "allowHitsOutsideBounds"> & import("react").RefAttributes<unknown>>;
922
KeyboardAwareInsetsView: {
1023
(props: KeyboardTrackingViewProps): JSX.Element;
1124
displayName: string;

lib/components/Keyboard/KeyboardTracking/KeyboardTrackingView/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React from 'react';
1+
import React, {forwardRef} from 'react';
22
import {Platform, ViewStyle, ViewProps} from 'react-native';
33
import {default as KeyboardTrackingViewIOS} from './KeyboardTrackingView.ios';
44
import {default as KeyboardTrackingViewAndroid} from './KeyboardTrackingView.android';
55

6-
const IsAndroid = Platform.OS === 'android';
6+
const isAndroid = Platform.OS === 'android';
77

88
export type KeyboardTrackingViewProps = ViewProps & {
99
/**
@@ -37,14 +37,14 @@ export type KeyboardTrackingViewProps = ViewProps & {
3737
style?: ViewStyle;
3838
}
3939

40-
const KeyboardTrackingView = ({children, ...others}: KeyboardTrackingViewProps) => {
41-
const KeyboardTrackingViewContainer = IsAndroid ? KeyboardTrackingViewAndroid : KeyboardTrackingViewIOS;
40+
const KeyboardTrackingView = ({children, ...others}: KeyboardTrackingViewProps, ref: any) => {
41+
const KeyboardTrackingViewContainer = isAndroid ? KeyboardTrackingViewAndroid : KeyboardTrackingViewIOS;
4242

4343
return (
44-
<KeyboardTrackingViewContainer {...others}>
44+
<KeyboardTrackingViewContainer {...others} ref={ref}>
4545
{children}
4646
</KeyboardTrackingViewContainer>
4747
);
4848
};
4949

50-
export default KeyboardTrackingView;
50+
export default forwardRef(KeyboardTrackingView);

0 commit comments

Comments
 (0)