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

Fix scrolling problem for LHN #2406

Merged
merged 4 commits into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion src/components/IOUConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,10 @@ class IOUConfirmationList extends Component {

render() {
return (
<View style={[styles.flex1, styles.w100]}>
<View style={[styles.flex1, styles.w100, styles.justifyContentBetween]}>
<View style={[styles.flex1]}>
<OptionsList
listContainerStyles={[styles.flexGrow0]}
sections={this.getSections()}
disableArrowKeysActions
hideAdditionalOptionStates
Expand Down
6 changes: 5 additions & 1 deletion src/components/OptionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const propTypes = {
// option Background Color
optionBackgroundColor: PropTypes.string,

// option flexStyle for the options list container
listContainerStyles: PropTypes.arrayOf(PropTypes.object),

// Style for hovered state
// eslint-disable-next-line react/forbid-prop-types
optionHoveredStyle: PropTypes.object,
Expand Down Expand Up @@ -77,6 +80,7 @@ const defaultProps = {
optionBackgroundColor: undefined,
optionHoveredStyle: undefined,
contentContainerStyles: [],
listContainerStyles: [],
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see the issue now, if you give this a default value of undefined the solution will work because below you are checking:

this.props.listContainerStyles ? this.props.listContainerStyles : [styles.flex1]

and empty array will be truthy value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh my bad 😅

sections: [],
focusedIndex: 0,
selectedOptions: [],
Expand Down Expand Up @@ -196,7 +200,7 @@ class OptionsList extends Component {

render() {
return (
<View style={[styles.flexGrow0]}>
<View style={[...(this.props.listContainerStyles ? this.props.listContainerStyles : [styles.flex1])]}>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this can be rewritten as

Suggested change
<View style={[...(this.props.listContainerStyles ? this.props.listContainerStyles : [styles.flex1])]}>
<View style={[...(this.props.listContainerStyles || [styles.flex1])]}>

Copy link
Contributor

@TomatoToaster TomatoToaster Apr 15, 2021

Choose a reason for hiding this comment

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

Though I'm a little unsure about the use of spread syntax here. Wouldn't [...(x)] be equal to just x?

I think this can be further simplified to:

Suggested change
<View style={[...(this.props.listContainerStyles ? this.props.listContainerStyles : [styles.flex1])]}>
<View style={this.props.listContainerStyles || [styles.flex1]}>

Is there a specific reason you'd want to have the syntax in my comment above instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah if we want to make this super clean we can just do this

const defaultProps = {
    listContainerStyles: [styles.flex1],
};

...
<View style={this.props.listContainerStyles}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marcaaron I love this clean solution! Will implement it and push it. Thank you!

{this.props.headerMessage ? (
<View style={[styles.ph5, styles.pb5]}>
<Text style={[styles.textLabel, styles.colorMuted]}>
Expand Down