Closed cruiserkernan closed 7 months ago
If you come to MapLegends, do nothing and go to other pages. In such case it get null reference error. Fixed with this commit. https://github.com/rungwiroon/BlazorGoogleMaps/commit/b2d33c86c2db7d4d9b88d780c2df5e768d2f6dc5
Description
This pull request fixes a bug introduced in v3.3.1, issue #298, where OnClick events from elements in custom controls stopped working. It also disposes used resources.
Implemented Changes
objectManager.js:
Issue Addressed: Previously, elem.clone() was used, which led to problems with OnClick events in Blazor. Cloning a DOM element does not copy event listeners attached to it, causing loss of interactivity.
Resolution: Removed the cloning process. Now, the original element (elem) is directly used, preserving its event listeners and functionality.
Multi-map Support: Adjusted the controlParents object to handle controls from multiple maps.
Proper Disposal: Ensured that controlParents is disposed of correctly when a map is removed.
Addition and Removal Logic: With the removal of elem.clone(), the addition and removal logic for controls now deals directly with the original elements, ensuring that their state and events are preserved.
Visibility and Parent Management: Controls are now shown or hidden as needed and are always returned to their original parent when removed from the map, maintaining the expected behavior.
New and Updated Examples
New: MapsLegendPage
Demonstrates custom controls in multi-map scenarios, highlighting independent control management across different maps.
Updated: MapLegendPage
Showcases enhanced add/remove control features with event handling, focusing on Blazor component interactions.
Thank you for considering this pull request!