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

オープン
#2,512 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
react, typescript
領域
frontend

調査の方向性

まず、リンクされた CodeSandbox の再現を実行し、両方のマップで reuseMaps を有効にした状態で Unmount/Mount を数回切り替えます。reuseMaps の再マウント処理とメインマップの moveend イベントを追跡し、その後、再マウントによってミニマップのズームが変わらず、間違ったマップのビュー状態が報告されないことを確認します。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
TypeScript
スター
8.5k
フォーク
1.3k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

visgl/react-map-gl のほかの issue

visgl/react-map-gl の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。