File tree 1 file changed +17
-2
lines changed
src/explore-education-statistics-common/src/modules/charts/components
1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -88,8 +88,7 @@ export default function MapGeoJSON({
88
88
89
89
useEffect ( ( ) => {
90
90
if ( ! selectedFeature ) {
91
- // reset zoom
92
- map . setZoom ( 5 ) ;
91
+ resetZoom ( ) ;
93
92
return ;
94
93
}
95
94
@@ -107,6 +106,8 @@ export default function MapGeoJSON({
107
106
}
108
107
} , [ map , selectedFeature ] ) ;
109
108
109
+ const resetZoom = ( ) => map . setZoom ( 5 ) ;
110
+
110
111
// We have to assign our `onEachFeature` callback to a ref
111
112
// as `onEachFeature` forms an internal closure which
112
113
// prevents us from updating the callback's dependencies.
@@ -206,6 +207,20 @@ export default function MapGeoJSON({
206
207
onSelectFeature ( feature ) ;
207
208
}
208
209
} ,
210
+ keydown : e => {
211
+ if ( e . originalEvent . code === 'Tab' ) {
212
+ // https://dfedigital.atlassian.net/browse/EES-5910
213
+ // Reset the map zoom when user tabs through regions
214
+ // to ensure tooltips that appear are in bounds and visible
215
+ resetZoom ( ) ;
216
+ } else if ( e . originalEvent . code === 'Enter' ) {
217
+ // Also allow a feature to be 'selected' by pressing Enter
218
+ const { feature } = e . sourceTarget ;
219
+ if ( feature . properties && feature . id ) {
220
+ onSelectFeature ( feature ) ;
221
+ }
222
+ }
223
+ } ,
209
224
} }
210
225
/>
211
226
) }
You can’t perform that action at this time.
0 commit comments