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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

SectionList ListHeaderComponent gets rerendered when sections data changes #23400

Open
compojoom opened this issue Feb 12, 2019 · 8 comments
Open
Labels
Bug Component: SectionList Ran Commands One of our bots successfully processed a command.

Comments

@compojoom
Copy link
Contributor

compojoom commented Feb 12, 2019

馃悰 Bug Report

This is a duplicate of:
#16824
#16823
#14249

But since those 3 were closed and they are missing a reproducible example of the bug I'm reopening.

Description

If one uses a TextInput as a ListHeaderComponent when searching and when the returned sections are empty the TextInput loses focus.

If when searching the sections still have data - then the TextInput in the ListHeaderComponent doesn't lose focus.

To Reproduce

https://snack.expo.io/H12h3BgHV

Expected Behavior

I would expect for the TextInput not to lose focus

Code Example

https://snack.expo.io/H12h3BgHV

Environment

[skip envinfo]
RN 0.58

I've been trying to debug this with @pawelczerepak and what we noticed is that VirtualizedCellWrapper
https://github.com/facebook/react-native/blob/master/Libraries/Lists/VirtualizedList.js#L1759
gets unmounted and mounted when sections is an empty array. And when this happens everything inside of it gets unmounted and mounted again.
@sahrens - any ideas on what might be going on here?

@react-native-bot
Copy link
Collaborator

Can you run react-native info and edit your issue to include these results under the Environment section?

If you believe this information is irrelevant to the reported issue, you may write [skip envinfo] under Environment to let us know.

@sahrens
Copy link
Contributor

sahrens commented Feb 13, 2019

Thanks for the great repro! I'm not sure what the issue is, but re-mounting sounds like a likely candidate.

@react-native-bot
Copy link
Collaborator

I am closing this issue because it does not contain the necessary environment info, and there has been no followup in a while.

If you found this thread after encountering the same issue in the latest release, please feel free to create a new issue with up-to-date information by clicking here.

@react-native-bot react-native-bot added the Ran Commands One of our bots successfully processed a command. label Feb 21, 2019
@compojoom
Copy link
Contributor Author

H盲??? wtf?

There is no need for envinfo as it doesn't matter. It happens on the latest RN release and I have a snack that reproduces the issue.

@facebook-github-bot reopen

@sahrens?

@kneza23
Copy link

kneza23 commented Apr 1, 2019

Yeah, it is still an issue. Happens everytime you empty your sections. Shame that this is closed. Anyone has at least a hack/quick fix to resolve this?

@eahrold
Copy link

eahrold commented Aug 4, 2019

I'd like to note this behavior also occurs on the ListFooterComponent.

@ospfranco
Copy link
Contributor

Still experiencing this issue, sad to see bot closing it and nobody doing anything about it.

@ospfranco
Copy link
Contributor

As a dirty workaround I simply turn on the autofocus if there is some query already inputed:

 private renderSearchHeader = () => {
    const { searchQuery, setSearchQuery } = this.props;
    return (
      <Translation ns="common">
        {t => (
          <Row
            style={{ padding: 10, backgroundColor: 'white', height: 56 }}
            vertical="center"
          >
            <Icon
              name="magnify"
              size={22}
              color={variables.colors.disabledActionItem}
            />
            <TextInput
              style={{ flex: 1 }}
              placeholder={t('search')}
              value={searchQuery}
              onChangeText={setSearchQuery}
              autoFocus={!!searchQuery} // Get around RN bug
            />
          </Row>
        )}
      </Translation>
    );
  };

@facebook facebook locked as resolved and limited conversation to collaborators Feb 21, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Feb 21, 2020
@satya164 satya164 reopened this Apr 26, 2020
@satya164 satya164 removed the Resolution: Locked This issue was locked by the bot. label Apr 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Component: SectionList Ran Commands One of our bots successfully processed a command.
Projects
None yet
Development

No branches or pull requests

7 participants