graphhopper/graphhopper-maps

Changing query point field adds extra history entry

Opened this issue · 1 comments

When we calculate a route, then clear a field, and then enter another location/point to calculate a new route two history entries are created. One for the empty field and another for the new one. The first one is caused by the InvalidatePoint action. This means that when we click 'back' after the change the route disappears as one field is empty and we need to click 'back' another time to go back to the previous route.

To fix this we need to deal with the fact that this user interaction (changing the input field) triggers two state updates and we create a history entry for every state update. One possibility would be creating history entries explicitly instead of using our current indirect approach.

Currently we dispatch InvalidatePoint on every keystroke, but probably it makes more sense to call it only if the input looses focus (click elsewhere/tab) or explicit enter with empty string. And then it might be fine to add this explicit action into history.