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

[Bugfix][SwipeableFlatList] Fix SwipeableFlatList on close #16682

Closed
wants to merge 2 commits into from
Closed

[Bugfix][SwipeableFlatList] Fix SwipeableFlatList on close #16682

wants to merge 2 commits into from

Conversation

kesha-antonov
Copy link
Contributor

Motivation

This commit d8cc6e3 introduced SwipeableFlatList

It has bug - doesn't close on swipe other rows.

I fixed it.

Release Notes

[IOS/ANDROID] [BUGFIX] [SwipeableFlatList] - opened rows did not close on swipe other rows

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 5, 2017
@kesha-antonov kesha-antonov changed the title Fix swipeable flat list on close 1 [Bugfix][SwipeableFlatList] Fix SwipeableFlatList on close Nov 5, 2017
@pull-bot
Copy link

pull-bot commented Nov 5, 2017

Warnings
⚠️

📋 Test Plan - This PR appears to be missing a Test Plan.

⚠️

📋 Release Notes - This PR may have incorrectly formatted Release Notes.

@facebook-github-bot label Needs more information

@facebook-github-bot label Needs more information

Generated by 🚫 dangerJS

@eballeste
Copy link

What if we don't want the other rows to close automatically?

@kesha-antonov
Copy link
Contributor Author

Read source. It's by design

kesha-antonov referenced this pull request Nov 9, 2017
Reviewed By: sahrens

Differential Revision: D5912488

fbshipit-source-id: 3d2872a7712c00badcbd8341a7d058df14a9091a
@AntonPuko
Copy link

AntonPuko commented Nov 9, 2017

@kesha-antonov can you check, I think with your current solution all rows are rerendered on every swipe. If I'm wrong, cool then.

@@ -35,7 +35,9 @@ type SwipableListProps = {
type Props<ItemT> = SwipableListProps & FlatListProps<ItemT>;

type State = {
openRowKey: ?string,
extraData: {

Choose a reason for hiding this comment

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

why do we need extra object inside state? isn't it simpler keep it as before but put into flat list extraData={this.state} ?

Copy link
Contributor

Choose a reason for hiding this comment

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

@kesha-antonov

Following the example in https://facebook.github.io/react-native/docs/flatlist.html

By passing extraData={this.state} to FlatList we make sure FlatList itself will re-render when the state.selected changes. Without setting this prop, FlatList would not know it needs to re-render any items because it is also a PureComponent and the prop comparison will not show any changes.

@facebook-github-bot
Copy link
Contributor

@kesha-antonov I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project.

};

this._shouldBounceFirstRowOnMount = this.props.bounceFirstRowOnMount;

this.onRefFlatList = this.onRefFlatList.bind(this);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code works faster than fat arrow.
In render we should avoid create function every time
@tomasreimers

Copy link
Contributor

Choose a reason for hiding this comment

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

@kesha-antonov totally get that -- I meant why .bind(this) in the initializer instead of using class fields (like _onScroll)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ping

@vysotsky
Copy link

Waiting for this fix to be merged? Any updates on it?

@react-native-bot react-native-bot added Missing Changelog This PR appears to be missing a changelog, or they are incorrectly formatted. Ran Commands One of our bots successfully processed a command. labels Mar 16, 2018
@react-native-bot react-native-bot added the Missing Test Plan This PR appears to be missing a test plan. label May 15, 2018
@kesha-antonov
Copy link
Contributor Author

ping

@tomasreimers
Copy link
Contributor

Hi @kesha-antonov , I think this was fixed by #18001

@hramos hramos added the Resolution: Fixed A PR that fixes this issue has been merged. label Dec 11, 2018
@hramos hramos closed this Dec 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Missing Changelog This PR appears to be missing a changelog, or they are incorrectly formatted. Missing Test Plan This PR appears to be missing a test plan. Ran Commands One of our bots successfully processed a command. Resolution: Fixed A PR that fixes this issue has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants