arnaudleclerc / AzureMapsControl.Components

Razor Components for azure-maps-control
MIT License
34 stars 12 forks source link

Layer events affecting another sessions (other tabs, other users) #96

Closed phpb1997 closed 5 months ago

phpb1997 commented 7 months ago

Let's say we have user A and user B. And in the blazor app we have a layer in the azure map and some events in there, see a code as example:

layer.OnMouseOver += mouseEventArgs => { _navigationManager.NavigateTo("test"); };

If there's only user A, it will work fine, when the user hovers the mouse over the layer it will navigate to this test page.

But let's say User A opened the map, then User B. If User A over the mouse, it will open the page in User B tab. Why? Is this a bug or am I doing something wrong?

If someone can point what's wrong, I'll appreciate!

To Reproduce Steps to reproduce the behavior:

  1. Create a layer
  2. Add a event to layer
  3. Add layer to map
  4. Open two tabs
  5. Invoke events from first tab opened and see the reaction in another

Expected behavior The events should happen in the tab that invoked events

markbeau commented 5 months ago

I can confirm the same behavior.

In my case, I first ran into a problem when creating two independent map components within the same Blazor page, each with a mouseover event to display a popup on the map canvas. Whichever map after being rendered first receives a mouseover event works fine, until the second map processes a mouse event. Then events on the first map stop working and vice versa.

Thanks to @phpb1997, I tried opening a map in two different browser tabs and see the same behavior.

To Reproduce:

  1. Download and run the AzureMapsControls.Components.Sample
  2. Open the HTML marker popup sample in two different browser tabs or windows.
  3. Open browser developer tools => debug console
  4. Click on the marker in the first tab to open the popup.
  5. Click on the marker in the second tab, which will fail with an exception
  6. Refresh the second tab and click on the marker. The popup should open.
  7. Click again on the marker in the first tab, which will fail.

Expected behavior: Support for more than one map instance with event handling

arnaudleclerc commented 5 months ago

@phpb1997 @markbeau First of all, sorry for the delay!

Thanks to your description, I was also able to reproduce the issue and fix it. I just published a version 1.16.0-alpha0003. Could you please check if the issue is fixed with this version and give me a feedback ?

phpb1997 commented 5 months ago

@arnaudleclerc

Looks like it's fixed, I ran some tests and didn't find any issues anymore. Thank you so much! Have a great day!

arnaudleclerc commented 5 months ago

Glad to hear! Thanks for the feedback! I just published a stable version 1.16.0 with the fix, so I will close this issue.

markbeau commented 5 months ago

@arnaudleclerc Likewise, it's looking good here too. Thanks a bunch!!!