File tree Expand file tree Collapse file tree
pcd-website/src/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -145,7 +145,18 @@ function handleKeydown(e: KeyboardEvent) {
145145 const mapEl = document .getElementById (' map' );
146146 if (mapEl && (mapEl === document .activeElement || mapEl .contains (document .activeElement ))) {
147147 e .preventDefault ();
148- document .getElementById (' burger-btn' )?.focus ();
148+ mapEl .focus ();
149+ }
150+ }
151+ } else if (! isTextInput && / ^ [0-9 ] $ / .test (e .key )) {
152+ const mapEl = document .getElementById (' map' );
153+ if (mapEl && (mapEl .contains (document .activeElement ) || document .activeElement === mapEl )) {
154+ e .preventDefault ();
155+ e .stopPropagation ();
156+ if (e .key === ' 0' ) {
157+ mapInstance ?.setView ([20 , 10 ], 3 );
158+ } else {
159+ mapInstance ?.setZoom (parseInt (e .key ));
149160 }
150161 }
151162 } else if (e .key === ' M' || e .key === ' m' ) {
@@ -175,6 +186,13 @@ onMounted(async () => {
175186 mapInstance = map ;
176187 leafletRef = L ;
177188
189+ // Remove digit keyCodes (48–57) from Leaflet's built-in zoom handler so our
190+ // number-key zoom shortcuts don't conflict (e.g. keyCode 54 = '6' is zoom-out).
191+ const kb = (map as any ).keyboard ;
192+ if (kb ?._zoomKeys ) {
193+ for (let code = 48 ; code <= 57 ; code ++ ) delete kb ._zoomKeys [code ];
194+ }
195+
178196 L .control .zoom ({ position: ' bottomleft' }).addTo (map );
179197
180198 // Manage tab order for Leaflet-injected elements:
You can’t perform that action at this time.
0 commit comments