Skip to content

Commit

Permalink
Merge pull request #16443 from gedu/edu/15270_viewport_jumping_up
Browse files Browse the repository at this point in the history
Viewport jumping up
  • Loading branch information
Hayata Suenaga authored Apr 21, 2023
2 parents a33b719 + b90d6c8 commit 4341da6
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/components/ScreenWrapper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ class ScreenWrapper extends React.Component {
}

render() {
const maxHeight = this.props.shouldEnableMaxHeight ? this.props.windowHeight : undefined;

return (
<SafeAreaConsumer>
{({
Expand All @@ -120,7 +122,7 @@ class ScreenWrapper extends React.Component {
// eslint-disable-next-line react/jsx-props-no-spreading
{...(this.props.environment === CONST.ENVIRONMENT.DEV ? this.panResponder.panHandlers : {})}
>
<KeyboardAvoidingView style={[styles.w100, styles.h100, {maxHeight: this.props.windowHeight}]} behavior={this.props.keyboardAvoidingViewBehavior}>
<KeyboardAvoidingView style={[styles.w100, styles.h100, {maxHeight}]} behavior={this.props.keyboardAvoidingViewBehavior}>
<HeaderGap />
{(this.props.environment === CONST.ENVIRONMENT.DEV) && <TestToolsModal />}
{(this.props.environment === CONST.ENVIRONMENT.DEV) && <CustomDevMenu />}
Expand Down
4 changes: 4 additions & 0 deletions src/components/ScreenWrapper/propTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ const propTypes = {
/** Whether to dismiss keyboard before leaving a screen */
shouldDismissKeyboardBeforeClose: PropTypes.bool,

/** Whether to use the maxHeight (true) or use the 100% of the height (false) */
shouldEnableMaxHeight: PropTypes.bool,

...windowDimensionsPropTypes,

...environmentPropTypes,
Expand All @@ -47,6 +50,7 @@ const defaultProps = {
onEntryTransitionEnd: () => {},
modal: {},
keyboardAvoidingViewBehavior: 'padding',
shouldEnableMaxHeight: false,
};

export {propTypes, defaultProps};
2 changes: 1 addition & 1 deletion src/pages/NewChatPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class NewChatPage extends Component {
maxParticipantsReached,
);
return (
<ScreenWrapper includeSafeAreaPaddingBottom={false}>
<ScreenWrapper includeSafeAreaPaddingBottom={false} shouldEnableMaxHeight>
{({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => (
<>
<HeaderWithCloseButton
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/MoneyRequestDescriptionPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class MoneyRequestDescriptionPage extends Component {

render() {
return (
<ScreenWrapper includeSafeAreaPaddingBottom={false}>
<ScreenWrapper includeSafeAreaPaddingBottom={false} shouldEnableMaxHeight>
<HeaderWithCloseButton
title={this.props.translate('common.description')}
shouldShowBackButton
Expand Down
5 changes: 4 additions & 1 deletion src/pages/iou/MoneyRequestModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {withNetwork} from '../../components/OnyxProvider';
import reportPropTypes from '../reportPropTypes';
import * as ReportUtils from '../../libs/ReportUtils';
import * as ReportScrollManager from '../../libs/ReportScrollManager';
import * as DeviceCapabilities from '../../libs/DeviceCapabilities';

/**
* A modal used for requesting money, splitting bills or sending money.
Expand Down Expand Up @@ -367,8 +368,10 @@ const MoneyRequestModal = (props) => {
/>
);
const amountButtonText = isEditingAmountAfterConfirm ? props.translate('common.save') : props.translate('common.next');
const enableMaxHeight = DeviceCapabilities.canUseTouchScreen() && currentStep === Steps.MoneyRequestParticipants;

return (
<ScreenWrapper includeSafeAreaPaddingBottom={false}>
<ScreenWrapper includeSafeAreaPaddingBottom={false} shouldEnableMaxHeight={enableMaxHeight}>
{({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => (
<>
<View style={[styles.pRelative, styles.flex1]}>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/WorkspaceInvitePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class WorkspaceInvitePage extends React.Component {
const policyName = lodashGet(this.props.policy, 'name');

return (
<ScreenWrapper>
<ScreenWrapper shouldEnableMaxHeight>
{({didScreenTransitionEnd}) => (
<FullPageNotFoundView
shouldShow={_.isEmpty(this.props.policy)}
Expand Down

0 comments on commit 4341da6

Please sign in to comment.