Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SideNav doesn't work with HTTP links to pages in the same application. #5189

Closed
FDelporte opened this issue Jun 26, 2023 · 3 comments · Fixed by #6143
Closed

SideNav doesn't work with HTTP links to pages in the same application. #5189

FDelporte opened this issue Jun 26, 2023 · 3 comments · Fixed by #6143

Comments

@FDelporte
Copy link

FDelporte commented Jun 26, 2023

Description

When navigating from https://api.pi4j.com/system-information in the left menu to https://api.pi4j.com/swagger-ui/index.html, I first get "Could not navigate to 'swagger-ui/index.html'" but it's OK after a refresh... Idem for the link to "Open API".

Additional note: would be great if SideNavItem would allow to add a target="_blank". But I see, there is already a ticket for this: #5091

Expected outcome

Should open the page without error message

Minimal reproducible example

    private SideNav createNavigation() {
        SideNav nav = new SideNav();

        nav.addItem(
                new SideNavItem("Board Information", BoardInfoView.class, VaadinIcon.DATABASE.create()),
                new SideNavItem("System Information", SystemInfoView.class, VaadinIcon.INFO.create()),
                new SideNavItem("Open API", "https://api.pi4j.com/api/docs/pi4j", VaadinIcon.GLOBE.create()),
                new SideNavItem("Swagger UI - API", "https://api.pi4j.com/swagger-ui/index.html", VaadinIcon.GLOBE.create()),
                new SideNavItem("Pi4J Docs", "https://pi4j.com", VaadinIcon.GLOBE.create())
        );

        return nav;
    }

Full project is available here:
https://github.com/Pi4J/pi4j-board-info-service/blob/main/src/main/java/com/pi4j/boardinfoservice/views/BaseLayout.java#L55

Steps to reproduce

Application with the above code works OK for link 1, 2 and 5.
Other links give an error.

Environment

Vaadin version(s): 24.1.1
OS: Linux

Browsers

Firefox, Safari

@ugur-vaadin
Copy link
Contributor

I could not reproduce the issue using the example or the project. Can you please confirm if the issue still persists on your side? @FDelporte

@ugur-vaadin ugur-vaadin added the waiting for author Further information is requested label Jul 11, 2023
@FDelporte
Copy link
Author

FDelporte commented Jul 11, 2023

@ugur-vaadin yes, still exists in https://api.pi4j.com/, sources on https://github.com/Pi4J/pi4j-board-info-service/blob/main/src/main/java/com/pi4j/boardinfoservice/views/BaseLayout.java#L61

Happens both in Firefox and Safari on macOS.

Did you use a newer Vaadin version to test?

@vursen vursen removed the waiting for author Further information is requested label Mar 5, 2024
@vursen
Copy link
Contributor

vursen commented Mar 6, 2024

After an internal discussion, we've agreed that it would be beneficial to have an explicit API for marking side nav items to be ignored by the Vaadin router. The API can be also useful when you need an item to cause a full page refresh even though it points to a valid route. Since the Anchor component already has this API, it makes sense to take it as a reference.

Web component API:

<side-nav-item path="https://api.pi4j.com/swagger-ui/index.html" router-ignore>
  Swagger UI - API
</side-nav-item>

Flow component API:

SideNavItem sideNavItem = new SideNavItem(
    "Swagger UI - API", 
    "https://api.pi4j.com/swagger-ui/index.html"
);
sideNavItem.setRouterIgnore(true);

@vursen vursen added enhancement New feature or request and removed bug Something isn't working labels Mar 6, 2024
@ugur-vaadin ugur-vaadin removed their assignment Mar 8, 2024
@sissbruecker sissbruecker self-assigned this Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment