Skip to content

RouterLink is not working inside modal dialog #13270

Closed

Description

@knoobie

Description of the bug

Navigation using RouterLink is not possible inside a modal dialog.

Expected behavior

Any RouterLink inside the dialog can be used to navigate to another page.

Minimal reproducible example

    add(new Button("Open Modal Dialog", e -> {
      Dialog dialog = new Dialog(new RouterLink("Click Me", AnotherRoute.class));
      dialog.setModal(true);
      dialog.open();
    }));

Versions

  • Vaadin / Flow version: 23.0.0 / 23.0.1

Activity

  1. knoobie commented on Mar 10, 2022

    @knoobie
    ContributorAuthor

    Keep in mind that this is just a simple example; a more complex example is a RouterLink rendered with a LItRenderer inside a Grid which is inside the modal dialog where no direct parent/child relationship between the dialog and the RouterLink is available on the server side.

  2. caalador commented on Mar 11, 2022

    @caalador
    Contributor

    Seems RouterLink navigation is explicitly denied if UI is inert (in v14 bootstrap mode)

                // When the UI is made inert, all router link navigation is
                // ignored. For the part of the UI that is not inert, navigation
                // could be allowed by using something else than router links (with
                // server side listeners).
                // Blocking browser history back / forward navigation is not done
                // as it would be dubious and even impossible on the client side.
    

    This ofc shouldn't be the case when the navigation is from inside the modal component. For js bootstrap it is blocked in the connect client due to inert state navigation is blocked which is problematic as the UI is always inert if a modal component is set.

  3. added
    BFPBugfix priority, also known as Warranty
    on Mar 11, 2022
  4. anssit commented on Mar 16, 2022

    @anssit
    Contributor

    As pointed out above, it won't be easy to cover all uses of RouterLink inside a modal component. In fact, even the seemingly simple case has no obvious solution currently.

    Navigation has been disabled intentionally with the idea that typically one has little reason to navigate when in a modal component.

    We are curious about your use case @knoobie. Why do you need RouterLinks inside a modal, and why working around them by using something else than router links (with server side listeners) is not an option?

  5. knoobie commented on Mar 16, 2022

    @knoobie
    ContributorAuthor

    Simply accessibility - links (RouterLink) are the way to go for an inclusive webdesign. I currently have a workaround in place for the specific dialog (making it non-modal) but that was an undocumented behaviour change that should be at least be documented as limitation or mentioned somewhere (that is not a comment inside java code of flow)

  6. caalador commented on Mar 17, 2022

    @caalador
    Contributor

    I guess it should be documented as a limitation on each of the modal components documentation.

    Also I couldn't find documentation on the sever-side modality at all so that should be added to the advanced section.

  7. knoobie commented on Mar 17, 2022

    @knoobie
    ContributorAuthor

    Tbh I was kinda confused that a dialog is by default modal and you have to opt-out from it; that's how I stumbled upon it because I explicitly called setModal(true) on other dialogs but not on this one.

    (I know there is a sentence about it in the docs; still not expected default coming from other business application where you have multiple dialogs side by side opening and dragging them around)

  8. added a commit that references this issue on Mar 22, 2022
    8ea3378
  9. added a commit that references this issue on Mar 22, 2022
    4fd1619
  10. added a commit that references this issue on Mar 22, 2022
    738c055
  11. vaadin-bot commented on Mar 28, 2022

    @vaadin-bot
    Collaborator

    This ticket/PR has been released with Vaadin 23.0.3.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions