Skip to content

make sure to pass forward ref in KeyboardTrackingView component #1552

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

Merged
merged 1 commit into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,30 @@ export declare type KeyboardTrackingViewProps = ViewProps & {
children?: React.ReactChild | React.ReactChild[];
style?: ViewStyle;
};
declare const KeyboardTrackingView: ({ children, ...others }: KeyboardTrackingViewProps) => JSX.Element;
export default KeyboardTrackingView;
declare const _default: React.ForwardRefExoticComponent<Pick<ViewProps & {
/**
* Enables tracking of the keyboard when it's dismissed interactively (false by default).
* Why? When using an external keyboard (BT),
* you still get the keyboard events and the view just hovers when you focus the input.
* Also, if you're not using interactive style of dismissing the keyboard
* (or if you don't have an input inside this view) it doesn't make sense to track it anyway.
* (This is caused because of the usage of inputAccessory to be able to track the
* keyboard interactive change and it introduces this bug)
*/
trackInteractive?: boolean | undefined;
/**
* Allow control safe area
*/
useSafeArea?: boolean | undefined;
scrollToFocusedInput?: boolean | undefined;
scrollBehavior?: number | undefined;
revealKeyboardInteractive?: boolean | undefined;
manageScrollView?: boolean | undefined;
requiresSameParentToManageScrollView?: boolean | undefined;
addBottomView?: boolean | undefined;
allowHitsOutsideBounds?: boolean | undefined;
ref?: any;
children?: React.ReactChild | React.ReactChild[] | undefined;
style?: ViewStyle | undefined;
}, "children" | keyof ViewProps | "useSafeArea" | "trackInteractive" | "scrollToFocusedInput" | "scrollBehavior" | "revealKeyboardInteractive" | "manageScrollView" | "requiresSameParentToManageScrollView" | "addBottomView" | "allowHitsOutsideBounds"> & React.RefAttributes<unknown>>;
export default _default;
15 changes: 14 additions & 1 deletion generatedTypes/lib/components/Keyboard/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,20 @@ import KeyboardAccessoryView, { KeyboardAccessoryViewProps } from './KeyboardInp
import KeyboardUtils from './KeyboardInput/utils/KeyboardUtils';
export { KeyboardTrackingViewProps, KeyboardAccessoryViewProps };
declare const _default: {
KeyboardTrackingView: ({ children, ...others }: KeyboardTrackingViewProps) => JSX.Element;
KeyboardTrackingView: import("react").ForwardRefExoticComponent<Pick<import("react-native").ViewProps & {
trackInteractive?: boolean | undefined;
useSafeArea?: boolean | undefined;
scrollToFocusedInput?: boolean | undefined;
scrollBehavior?: number | undefined;
revealKeyboardInteractive?: boolean | undefined;
manageScrollView?: boolean | undefined;
requiresSameParentToManageScrollView?: boolean | undefined;
addBottomView?: boolean | undefined;
allowHitsOutsideBounds?: boolean | undefined;
ref?: any;
children?: import("react").ReactChild | import("react").ReactChild[] | undefined;
style?: import("react-native").ViewStyle | undefined;
}, "children" | keyof import("react-native").ViewProps | "useSafeArea" | "trackInteractive" | "scrollToFocusedInput" | "scrollBehavior" | "revealKeyboardInteractive" | "manageScrollView" | "requiresSameParentToManageScrollView" | "addBottomView" | "allowHitsOutsideBounds"> & import("react").RefAttributes<unknown>>;
KeyboardAwareInsetsView: {
(props: KeyboardTrackingViewProps): JSX.Element;
displayName: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import React, {forwardRef} from 'react';
import {Platform, ViewStyle, ViewProps} from 'react-native';
import {default as KeyboardTrackingViewIOS} from './KeyboardTrackingView.ios';
import {default as KeyboardTrackingViewAndroid} from './KeyboardTrackingView.android';

const IsAndroid = Platform.OS === 'android';
const isAndroid = Platform.OS === 'android';

export type KeyboardTrackingViewProps = ViewProps & {
/**
Expand Down Expand Up @@ -37,14 +37,14 @@ export type KeyboardTrackingViewProps = ViewProps & {
style?: ViewStyle;
}

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

return (
<KeyboardTrackingViewContainer {...others}>
<KeyboardTrackingViewContainer {...others} ref={ref}>
{children}
</KeyboardTrackingViewContainer>
);
};

export default KeyboardTrackingView;
export default forwardRef(KeyboardTrackingView);