neuland-ingolstadt / neuland.app

A free & open source, web-based replacement for the official app of the Technische Hochschule Ingolstadt built with React and Next.js.
https://neuland.app
GNU Affero General Public License v3.0
36 stars 31 forks source link

Fix map view position reset on rerender #387

Closed alexhorn closed 6 months ago

alexhorn commented 6 months ago

Currently, the map view position jumps back to the center every time the map is rerendered. This can be reproduced by panning to a different location and then changing the location using the developer tools.

BuildmodeOne commented 6 months ago

Maybe I missed something, but isn't the inner component just renamed and moved to a different part of the file? I had issues in the past to reproduce this bug on Android/Windows. Just a note of caution, not that the bug still exists.

alexhorn commented 6 months ago

It took me a while to understand why the bug was happening myself. Because Recenter was declared inside RoomMap it was recreated every time RoomMap was rerendered, which happens every time there is a position update from the Geolocation API. Moving it outside the RoomMap component seems to fix that.

BuildmodeOne commented 6 months ago

@alexhorn Okay wow🫠