-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fix for: mWeb/Chrome - Payment - The keyboard overlaps the "Make default payment method" button #14725
Merged
Merged
Fix for: mWeb/Chrome - Payment - The keyboard overlaps the "Make default payment method" button #14725
Changes from 4 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2fc343c
Created HOC for viewportOffsetTop
Ollyws f4a1d49
Added disableCoverScreen prop for PasswordPopover
Ollyws a5cd3b9
Implemented withViewportOffsetTop HOC
Ollyws 8c260b5
Set Android KeyboardSpacer to null
Ollyws a3cc328
Deleted KeyboardSpacer index.android
Ollyws 663c71b
Added comment for disableCoverScreen prop
Ollyws 076c4dc
Merge branch 'Expensify:main' into issue-14003
Ollyws d011e99
Updated comment in KeyboardSpacer index
Ollyws 99bd6a7
Added comment for viewPortOffsetTop prop
Ollyws b09f1eb
Revert disableCoverScreen and screenWrapper style
Ollyws bd422a2
Revert keyboardSpacer changes
Ollyws 1359e05
Added extraModalStyles prop
Ollyws acca535
Added withViewportOffsetTop
Ollyws 483bf82
Merge branch 'main' into issue-14003
Ollyws 34401d3
Change modal style prop names
Ollyws File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,9 @@ | ||
/** | ||
* On Android the keyboard covers the input fields on the bottom of the view. This component moves the | ||
* view up with the keyboard allowing the user to see what they are typing. | ||
* On Android we do not need to implement a keyboard spacer, so we return a null component. | ||
* | ||
* @returns {null} | ||
* @constructor | ||
*/ | ||
import React from 'react'; | ||
import {StatusBar} from 'react-native'; | ||
import BaseKeyboardSpacer from './BaseKeyboardSpacer'; | ||
import withWindowDimensions, {windowDimensionsPropTypes} from '../withWindowDimensions'; | ||
const KeyboardSpacer = () => null; | ||
|
||
const KeyboardSpacer = () => ( | ||
<BaseKeyboardSpacer | ||
topSpacing={StatusBar.currentHeight} | ||
keyboardShowMethod="keyboardDidShow" | ||
keyboardHideMethod="keyboardDidHide" | ||
/> | ||
); | ||
|
||
KeyboardSpacer.propTypes = windowDimensionsPropTypes; | ||
KeyboardSpacer.displayName = 'KeyboardSpacer'; | ||
|
||
export default withWindowDimensions(KeyboardSpacer); | ||
export default KeyboardSpacer; | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import React, {Component} from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import lodashGet from 'lodash/get'; | ||
import getComponentDisplayName from '../libs/getComponentDisplayName'; | ||
import addViewportResizeListener from '../libs/VisualViewport'; | ||
|
||
const viewportOffsetTopPropTypes = { | ||
viewportOffsetTop: PropTypes.number.isRequired, | ||
jasperhuangg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
export default function (WrappedComponent) { | ||
class WithViewportOffsetTop extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.updateDimensions = this.updateDimensions.bind(this); | ||
|
||
this.state = { | ||
viewportOffsetTop: 0, | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
this.removeViewportResizeListener = addViewportResizeListener(this.updateDimensions); | ||
} | ||
|
||
componentWillUnmount() { | ||
this.removeViewportResizeListener(); | ||
} | ||
|
||
/** | ||
* @param {SyntheticEvent} e | ||
*/ | ||
updateDimensions(e) { | ||
const viewportOffsetTop = lodashGet(e, 'target.offsetTop', 0); | ||
this.setState({viewportOffsetTop}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<WrappedComponent | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...this.props} | ||
ref={this.props.forwardedRef} | ||
viewportOffsetTop={this.state.viewportOffsetTop} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
WithViewportOffsetTop.displayName = `WithViewportOffsetTop(${getComponentDisplayName(WrappedComponent)})`; | ||
WithViewportOffsetTop.propTypes = { | ||
forwardedRef: PropTypes.oneOfType([ | ||
PropTypes.func, | ||
PropTypes.shape({current: PropTypes.instanceOf(React.Component)}), | ||
]), | ||
}; | ||
WithViewportOffsetTop.defaultProps = { | ||
forwardedRef: undefined, | ||
}; | ||
return React.forwardRef((props, ref) => ( | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
<WithViewportOffsetTop {...props} forwardedRef={ref} /> | ||
)); | ||
} | ||
|
||
export { | ||
viewportOffsetTopPropTypes, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ import OfflineWithFeedback from '../../../../components/OfflineWithFeedback'; | |
import ConfirmContent from '../../../../components/ConfirmContent'; | ||
import Button from '../../../../components/Button'; | ||
import themeColors from '../../../../styles/themes/default'; | ||
import withViewportOffsetTop from '../../../../components/withViewportOffsetTop'; | ||
|
||
class BasePaymentsPage extends React.Component { | ||
constructor(props) { | ||
|
@@ -341,8 +342,9 @@ class BasePaymentsPage extends React.Component { | |
|
||
// Determines whether or not the modal popup is mounted from the bottom of the screen instead of the side mount on Web or Desktop screens | ||
const isPopoverBottomMount = this.state.anchorPositionTop === 0 || this.props.isSmallScreenWidth; | ||
const screenWrapperStyle = [{marginTop: this.props.viewportOffsetTop}]; | ||
return ( | ||
<ScreenWrapper> | ||
<ScreenWrapper style={screenWrapperStyle}> | ||
<HeaderWithCloseButton | ||
title={this.props.translate('common.payments')} | ||
shouldShowBackButton | ||
|
@@ -478,6 +480,7 @@ class BasePaymentsPage extends React.Component { | |
)} | ||
</Popover> | ||
<PasswordPopover | ||
disableCoverScreen | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's add comment what this prop is for |
||
isVisible={this.state.shouldShowPasswordPrompt} | ||
onClose={this.hidePasswordPrompt} | ||
anchorPosition={{ | ||
|
@@ -499,6 +502,7 @@ BasePaymentsPage.propTypes = propTypes; | |
BasePaymentsPage.defaultProps = defaultProps; | ||
|
||
export default compose( | ||
withViewportOffsetTop, | ||
withWindowDimensions, | ||
withLocalize, | ||
withNetwork(), | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ollyws Now that this file is removed, we may need to change comment in
index.js
On non native platforms we do not need to implement a keyboard spacer, so we return a null component.
to something like this:
On non iOS platforms we do not need to implement a keyboard spacer, so we return a null component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aimane-chnaif All done.