Skip to content

GitHub Issue #1023: Add redirect() helper that uses core-safeRedirect #2021

Open
cnathe wants to merge 9 commits into
developfrom
fb_redirectGH1023
Open

GitHub Issue #1023: Add redirect() helper that uses core-safeRedirect #2021
cnathe wants to merge 9 commits into
developfrom
fb_redirectGH1023

Conversation

@cnathe

@cnathe cnathe commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Rationale

https://github.com/LabKey/internal-issues/issues/1023

In the related PR, we added usages of the core-safeRedirect action. This PR moves that into a redirect() helper that can be used instead of setting window.location.href.

Related Pull Requests

Changes

  • Add redirect() helper that uses core-safeRedirect

@cnathe cnathe requested a review from labkey-alan June 23, 2026 17:23
}

window.location.href = url.toString();
redirect(url.toString());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@labkey-alan let me know what you think of this change. This would force the usages of navigate() to be internal redirect/navigations only...but I assume that was the intent and all usages are internal URLs. If there is a need for an external redirect / navigate, it was likely using window.location.href directly, right?

@labkey-alan labkey-alan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works well in my testing and I am comfortable approving it as-is. However, there is one clear gap that we should consider addressing if we can, but I am also comfortable deferring as long as we document the problem somewhere.

We have several stragglers in our product that still use window.location.href = someAppURL.toHref(), and for the most part those can be converted without issue, however the current implementation of redirect will not work with the case in FolderManagementPage.tsx, when a user deletes the container they're currently in. I updated this usage locally and what happens is we delete the container, then navigate to the safeRedirect action for the container we just deleted, which 404's. We should probably put a comment in FolderManagementPage.tsx to document this issue. I think moving forward we may need to have redirect try to generate the safeRedirect URL for the target container.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants