Skip to content

EES-5910 Ensure tooltips visible when tabbing through map regions #5713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ export default function MapGeoJSON({

useEffect(() => {
if (!selectedFeature) {
// reset zoom
map.setZoom(5);
resetZoom();
return;
}

Expand All @@ -107,6 +106,8 @@ export default function MapGeoJSON({
}
}, [map, selectedFeature]);

const resetZoom = () => map.setZoom(5);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to reset the position also? the default position is available in the parent component so could be used if so


// We have to assign our `onEachFeature` callback to a ref
// as `onEachFeature` forms an internal closure which
// prevents us from updating the callback's dependencies.
Expand Down Expand Up @@ -206,6 +207,20 @@ export default function MapGeoJSON({
onSelectFeature(feature);
}
},
keydown: e => {
if (e.originalEvent.code === 'Tab') {
// https://dfedigital.atlassian.net/browse/EES-5910
// Reset the map zoom when user tabs through regions
// to ensure tooltips that appear are in bounds and visible
resetZoom();
} else if (e.originalEvent.code === 'Enter') {
// Also allow a feature to be 'selected' by pressing Enter
const { feature } = e.sourceTarget;
if (feature.properties && feature.id) {
onSelectFeature(feature);
}
}
},
}}
/>
)}
Expand Down