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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unmounting of Callout Elements doesn't work #56

Closed
nikischin opened this issue May 1, 2024 · 5 comments · Fixed by #58 · May be fixed by #63
Closed

Unmounting of Callout Elements doesn't work #56

nikischin opened this issue May 1, 2024 · 5 comments · Fixed by #58 · May be fixed by #63

Comments

@nikischin
Copy link
Contributor

I just figured out the unmounting of the callout elements implemented with #55 doesn't work.

I implemented the new feature into my app and whenever you navigate to some other view all the annotations overlay the screen. I first thought it would be something related to React Router having issues with Portals but seems like a rather general issue to me.

I will further investigate these days and probably also submit a PR to fix, though wanted to open this bug already if someone comes up with the same issue.

@nikischin
Copy link
Contributor Author

So to give you an update on this, I investigated the issue and it's not as trivial as I expected it to be. I build a modified storybook example (Marker with custom callout element) at https://github.com/nikischin/mapkit-react/tree/bugfix/customCallout

The error provided looks like this whenever the map is unmount:
image

I will try further investigate, if you have any experience with similar issues, let me know

@nikischin
Copy link
Contributor Author

Screenshot

So while the error above is fixed in my implementation, I still get my app crashing whenever a callout is active and the user navigates to another page where the is being unmount. I wasn't able to reproduce this in the storybook so I will further investigate on what's the issue.

@nikischin
Copy link
Contributor Author

nikischin commented May 21, 2024

So while the error above is fixed in my implementation, I still get my app crashing whenever a callout is active and the user navigates to another page where the is being unmount. I wasn't able to reproduce this in the storybook so I will further investigate on what's the issue.

So I further investigated and it was really challenging to reproduce the error within storybook. However, I found out that in my use case it is quite likely that two (or more) locations have the exactly same coordinates. This works fine with <Markers/>, however not with <Annotations/>.

For more context why it is likely that two points share the exactly same coordinates in my implementation, imagine you have few contacts you would like to display on a map which might share the same address.

As I am able to reproduce, I will try to further investigate.

@nikischin
Copy link
Contributor Author

nikischin commented May 21, 2024

image This is the storybook error which gave the chance to further look into the mapkit-js error which does happen here: image So what I figured out, as a possible workaround, if the size of the element is set, it will not crash, however, in my implementation, I would like the sizing of the callouts to be dynamic based on the content width if possible. And also this introduces the possibility of other errors for some reason I don't yet understand.

@nikischin
Copy link
Contributor Author

So I further investigated and still find this quite confusing. What I noticed, is that the Annotations doesn't even need to have the same coordinates in order to cause this issue, it rather depends on the DOM point they are rendered to, though depending on the current zoom level you might or might not encounter this bug. I have a reproduction committed at https://github.com/nikischin/mapkit-react/tree/bugfix/customcallout2 in case you would like to have a look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant