react / react/react-native

SectionList ListHeaderComponent gets rerendered when sections data changes

Đang mở
#23,400 8 bình luận 2 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Bug Component: SectionList Ran Commands
Ngôn ngữ chính
C++
Star
127k
Fork
25.3k
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
4

Mô tả

🐛 Bug Report

This is a duplicate of:
https://github.com/facebook/react-native/issues/16824
https://github.com/facebook/react-native/issues/16823
https://github.com/facebook/react-native/issues/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?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Tái hiện việc mất tiêu điểm bằng ví dụ Snack, sau đó kiểm tra mã VirtualizedCellWrapper quanh dòng 1759 của Libraries/Lists/VirtualizedList.js. Theo dõi lý do nó bị unmount rồi mount lại khi sections trở thành rỗng, và xác minh rằng TextInput trong ListHeaderComponent vẫn giữ focus trong khi dữ liệu của các section thay đổi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
react-native
Lĩnh vực
mobile
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.