solidjs / solid-router

A universal router for Solid inspired by Ember and React Router
MIT License
1.13k stars 143 forks source link

additional option to `<A>` for top menus? #299

Closed mathieuprog closed 12 months ago

mathieuprog commented 12 months ago

Say a top menu Wallets:

<A class={styles.link} href={getRoute(/* ... */)} onClick={handleClick}>
  Wallets
</A>

Link:

href="/organization/dc70c79c-5c09-4de4-8728-8e82cb3884e6/wallets"

The page rendered is a list of wallets. When clicking on a wallet, the location becomes:

/organization/dc70c79c-5c09-4de4-8728-8e82cb3884e6/wallets/ff2605f4-1f50-4de7-a3a0-ecd4fc4843bd

It would be nice to have an additional option e.g. a boolean top, which allows to activate the menu when the href starts with the current location.

There's already an option end but surprisingly it does kinda the opposite, it checks whether the current location starts with href. By the way this also made me wonder, for what kind of pages is end useful?

ryansolid commented 12 months ago

Oh that is odd. I thought end was was to force exact matches because say a link to / would always be active otherwise by default.

mathieuprog commented 12 months ago

Sorry Ryan, misread the doc and all is fine now. I do not understand the naming end, I agree with this person: https://github.com/solidjs/solid-router/pull/179#issuecomment-1272236181

Thank you so much for your reply <3