Skip to content
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

chore: MapAndLabel tidy ups #3643

Merged
merged 3 commits into from
Sep 9, 2024
Merged

Conversation

jessicamcinchak
Copy link
Member

@jessicamcinchak jessicamcinchak commented Sep 9, 2024

A few tidy ups & fixes now that all major functionality is merged & open for testing ! Follows on from #3625

Fixes here:

  • Tabs correctly sorted - previous bug where 10 was getting sorted before 2 because geojson properties require labels to be stored as strings, but we want to sort them as numbers
  • activeTabIndex more consistently managed based on length of features when adding & removing features
  • After removing a feature, make zoom / map viewport repositioning less jumpy

Known still-outstanding bugs, to address in followup PRs:

  • When modifying a feature on the map, set corresponding tab as active index (modified feature will be last item in features array)
  • When coming "back"/"changing", ensure latest tab is set as active one & all tabs are edit-able
  • When coming "back"/"changing", ensure features can be added/removed in addition to editing existing features

Copy link

github-actions bot commented Sep 9, 2024

Removed vultr server and associated DNS entries

@jessicamcinchak jessicamcinchak marked this pull request as ready for review September 9, 2024 14:24
@jessicamcinchak jessicamcinchak requested a review from a team September 9, 2024 14:24
// Set active index as highest tab after removal, so that when you "add" a new feature the tabs increment correctly
setActiveIndex((features && features.length - 2) || activeIndex - 1);
setActiveIndex((features && features.length - 2) || 0);
Copy link
Member Author

Choose a reason for hiding this comment

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

If this is - 1 rather than - 2, then there's a known bug:

  • Add three features
  • Remove feature 3 - active tab is tab 2
  • Remove feature 2 - active tab is NOT tab 1 as expected

One to keep thinking on, still not completely satisfied with this solution !

};

const addInitialFeaturesToMap = (features: Feature[]) => {
setFeatures(features);
// TODO: setActiveIndex ?
// setActiveIndex(features.length - 1);
Copy link
Member Author

Choose a reason for hiding this comment

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

This looks like the right solution to me, and it does indeed mean the latest tab will be active/open when coming "back", but it unexpectedly make all other tabs un-clickable - so noted in PR description as outstanding bug

@jessicamcinchak jessicamcinchak merged commit 2fab60d into main Sep 9, 2024
12 checks passed
@jessicamcinchak jessicamcinchak deleted the jess/map-and-label-tidy-ups branch September 9, 2024 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants