Skip to content
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

Viewport jumping up #16443

Merged
merged 17 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
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.lockHeight ? null : this.props.windowHeight;

return (
<SafeAreaConsumer>
{({
Expand All @@ -118,7 +120,7 @@ class ScreenWrapper extends React.Component {
paddingStyle,
]}
>
<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}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we depend on Dimensions (windowHeight) inside KeyboardAvoidingView/index.web.js and apply maxHeight there? That would be a clean symmetry to the index.ios.js implementation and would reflect the general contract of the built-in KeyboardAvoidingView.

The shouldEnableMaxHeight would need to be forwarded to the in-house KeyboardAvoidingView, but would be accessed only on the Web implementation, which would improve clarity. Because the maxHeight thing is only for the Web, right?

I know that this PR does not introduce this code, but it does the biggest changes around it in a while, so if the original implementation was created in a way I'd describe as "confusing", I think we should clean it up here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then, we'd also have a good place to comment on which browsers actually need that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gedu, what do you think about this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No inline styles cc: @thesahindia

<HeaderGap />
{// If props.children is a function, call it to provide the insets to the children.
_.isFunction(this.props.children)
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 @@ -31,6 +31,9 @@ const propTypes = {

/** Whether to dismiss keyboard before leaving a screen */
shouldDismissKeyboardBeforeClose: PropTypes.bool,

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

const defaultProps = {
Expand All @@ -41,6 +44,7 @@ const defaultProps = {
onEntryTransitionEnd: () => {},
modal: {},
keyboardAvoidingViewBehavior: 'padding',
lockHeight: false,
};

export {propTypes, defaultProps};
1 change: 1 addition & 0 deletions src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class BaseSidebarScreen extends Component {
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
style={[styles.sidebar]}
lockHeight
>
{({insets}) => (
<>
Expand Down
8 changes: 7 additions & 1 deletion src/pages/iou/IOUModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,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';

/**
* IOU modal for requesting money and splitting bills.
Expand Down Expand Up @@ -420,8 +421,13 @@ class IOUModal extends Component {
render() {
const currentStep = this.steps[this.state.currentStepIndex];
const reportID = lodashGet(this.props, 'route.params.reportID', '');

// We want to lock the height of the screen when the IOUAmount page is visible
// so that the keyboard doesn't cause the screen to resize and move the NumberPad up and down
const lockHeight = DeviceCapabilities.canUseTouchScreen() && currentStep === Steps.IOUAmount;

return (
<ScreenWrapper includeSafeAreaPaddingBottom={false}>
<ScreenWrapper includeSafeAreaPaddingBottom={false} lockHeight={lockHeight}>
{({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => (
<>
<View style={[styles.pRelative, styles.flex1]}>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/Profile/ProfilePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const ProfilePage = (props) => {
];

return (
<ScreenWrapper includeSafeAreaPaddingBottom={false}>
<ScreenWrapper includeSafeAreaPaddingBottom={false} lockHeight>
<HeaderWithCloseButton
title={props.translate('common.profile')}
shouldShowBackButton
Expand Down