[Bug] onMoveEnd event is fired on second map on remount with reuseMaps

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

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

Đánh giá

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

Hướng nghiên cứu

Bắt đầu bằng cách chạy bản tái hiện CodeSandbox được liên kết và chuyển đổi Unmount/Mount vài lần với reuseMaps được bật cho cả hai bản đồ. Theo dõi việc xử lý remount của reuseMaps và sự kiện moveend của bản đồ chính, sau đó xác minh rằng việc remount không làm thay đổi mức thu phóng của bản đồ mini và không báo cáo trạng thái chế độ xem của bản đồ sai.

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

Mô tả

bug
Description

I have a main map and a mini map.
I would like the view state of the main map to drive the mini map, however the mini map should always be 2 zoom levels lower than the main map.
The main map is uncontrolled, the mini map is controlled.
The main map view state is stored in React state which updates when the main map moveend event fires.

The maps appear in a modal, so are unmounted and remounted as the modal is opened and closed. So I also have reuseMaps added to reduce mapbox map loads from the frequent mounting.

Each time the maps are remounted, the mini map zoom level decreases by 2 without moving the main map.
This only occurs when reuseMaps is set for both maps. But of course, I'd like to reuse both to save on map loads :)

The bug appears to be, at least, that the moveend callback for the main map is fired with the zoom level of the mini map, NOT the main map
You can see in the logs of the moveend callback that the zoom of the event view state doesn't match the main map zoom even when not changing the main map zoom. and the ID of the container for the event is indeed the main map.

But additionally may be that the moveend callback fires when the maps remount, when in reuse mode? does remount when reuse is on count as a move event?

Expected Behavior

moveend doesn't fire with reuse + remount? Or at least, the zoom of the event should match to the map the handler is attached to.
The zoom level of the mini map shouldn't change.

Steps to Reproduce

https://codesandbox.io/p/sandbox/epic-liskov-mymg27

Click Unmount/Mount several times to observe the mini map zoom level decreases each time

Environment
Logs

No response

Ngôn ngữ chính
TypeScript
Star
8.5k
Fork
1.3k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

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.

Issue khác của visgl/react-map-gl

Tất cả issue của visgl/react-map-gl

Issue tương tự

Thêm issue về TypeScript

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.