@tpzdsp/next-toolkit 1.12.4 → 1.12.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tpzdsp/next-toolkit",
3
- "version": "1.12.4",
3
+ "version": "1.12.5",
4
4
  "description": "A reusable React component library for Next.js applications",
5
5
  "engines": {
6
6
  "node": ">= 24.12.0",
@@ -89,12 +89,8 @@ export const MapComponent = ({
89
89
  const attribution = new Attribution();
90
90
  const layerSwitcher = new LayerSwitcherControl(layers);
91
91
 
92
- // Add controls in the desired order
93
- const controls = [mapZoom, layerSwitcher, scaleLine, attribution];
94
-
95
92
  const newMap = new Map({
96
93
  target,
97
- controls,
98
94
  layers,
99
95
  view: new View({
100
96
  projection: 'EPSG:3857',
@@ -108,12 +104,7 @@ export const MapComponent = ({
108
104
  }),
109
105
  });
110
106
 
111
- // Mark the map as initialized to prevent re-initialization
112
- // This is a workaround to avoid re-initializing the map when the component
113
- // re-renders. The map is only initialized once when the component mounts.
114
- // This is important because the map is a singleton and should not be
115
- // re-initialized.
116
- mapInitializedRef.current = true;
107
+ const controls = [mapZoom, layerSwitcher, scaleLine, attribution];
117
108
 
118
109
  // Create an instance of the custom provider, passing any options that are
119
110
  // required
@@ -122,12 +113,23 @@ export const MapComponent = ({
122
113
  try {
123
114
  const geocoder = initializeGeocoder(osMapsApiKey, geocoderUrl, newMap);
124
115
 
125
- newMap.addControl(geocoder as Control);
116
+ // Put geocoder first so the tabbing order is sensible
117
+ controls.unshift(geocoder);
126
118
  } catch (error) {
127
119
  console.error('Failed to initialize geocoder:', error);
128
120
  }
129
121
  }
130
122
 
123
+ // Add controls in the desired order
124
+ controls.forEach((control) => newMap.addControl(control));
125
+
126
+ // Mark the map as initialized to prevent re-initialization
127
+ // This is a workaround to avoid re-initializing the map when the component
128
+ // re-renders. The map is only initialized once when the component mounts.
129
+ // This is important because the map is a singleton and should not be
130
+ // re-initialized.
131
+ mapInitializedRef.current = true;
132
+
131
133
  // Setup popup overlay
132
134
  const overlay = new Overlay({
133
135
  element: document.getElementById('popup-container') ?? undefined,