Skip to content

Document why the hash string shouldn't be used for navigation #2742

Not planned

Description

@vlukashov

When handling a navigation event, as a developer, I want to get the URL fragment of the current URL (i.e. the edit part of the /orders/12#edit URL).

With the new Router API that is not supported at the moment (flow-1.0.0.alpha6). There is no getFragment() method:

@Override
public void afterNavigation(AfterNavigationEvent event) {
	String fragment = event.getLocation().getFragment();
}

Activity

  1. Artur- commented on Oct 20, 2017

    @Artur-
    Member

    This is quite logical as the fragment is a browser side feature only. IMO it should be used for its real purpose (link anchors) and not for navigation (contrary to how Navigator works in Framework 8).

    The main reason is that the fragment is not sent to the server automatically so it is not available in the initial request.

  2. vlukashov commented on Oct 20, 2017

    @vlukashov
    Author

    That's a valid argument, but I would not give it too much weight since Flow is already relaying so many of other browser-only entities to the server, that adding another once does not change the big picture.

    In this ticket I am saying is that as a developer I want to use fragments for switching between different states of my views. I assume there are other developers out there who will want the same.

    If that's not implemented, please consider adding a compelling explanation into the docs why it's possible in Angular / Vue / React apps but now in Flow.

  3. knoobie commented on Oct 20, 2017

    @knoobie
    Contributor

    As I understand Flow correctly, you want to change from being a SPA to a full blown web-page-framework. While doing that, it would be a huge step in the wrong direction to use the # again.

    For example it can be quite handy to bookmark a specific position on a long page. (www.example.com/docs/4.0/headings#h5)

    Why not use something like the old fashioned Query String?

  4. pleku commented on Oct 23, 2017

    @pleku

    I would say fragments should not be used in this use case at all. Not sure why Vue or Angular or something else thinks that it is a valid case now, since there is a history API and everything, unlike when the FW navigation was done when it was not yet supported for all browsers, and thus #fragment was the best option.

  5. Legioth commented on Oct 24, 2017

    @Legioth
    Member

    I fully agree with the concerns expressed by various commenters. Using # for navigation is an outdated pattern from the times before all browsers supported the History API. The main reason for still using it would be to preserve legacy URLs and bookmarks.

    We might still want to mention the reasoning in some suitable part of the documentation, but I don't think we should implement any direct support.

  6. changed the title [-]Router: add access to the hash string via the `Location` interface[/-] [+]Document why the hash string shouldn't be used for navigation[/+] on Oct 24, 2017
  7. totally-not-ai commented on Dec 5, 2026

    @totally-not-ai
    Contributor

    Closing as not planned: using the URL fragment for navigation is an outdated pattern, and the fragment is never sent to the server in the initial request. Use path or query parameters for view state instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions