Skip to content

Handling link clicks to the current URL? #8

Open
@danielcompton

Description

We have a hamburger menu which takes over the whole page on mobile. Each of the links in the menu is just a regular <a> with a path another route. When the user clicks on a link to a page they're not currently on, our dispatch-fn is called and we navigate to the page we want to show.

The problem we're having is that if they click a menu link to a page that they're already on, the history update is short circuited. This prevents the NAVIGATE event from firing, so we never get a chance to act on the click in our normal route handling code. This means we never get an event to hide the menu.

I can see a few ways we can fix this on our side:

  1. Special case the links to the page that we're on and intercept the click before it makes it to pushy. Then we can just close the menu in our own code. This feels a bit gross though.
  2. Make the closing of the menu separate from our navigation code and always close the menu on any click to any of the links. This seems maybe ok?

I'm not sure if we just have a bad architecture here and should be structuring our code a bit differently. OTOH, it does seem like apps might want to be able to respond to link clicks to the page they're already on?

What do you think? Is this something that would make sense for pushy, or does it mix concerns badly?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions