Skip to content

Conversation

@amcgee
Copy link
Member

@amcgee amcgee commented Apr 8, 2025

DHIS2-19412

Specifying a base in html (<base href="__DHIS2_APP_BASE_URL__/" />) allows native anchor links with hash targets to always link to the base with hash appended (see MDN docs here).

Unfortunately, there is also a bug in react-router here which checks for a specified base.href attribute but then uses window.location.href instead of base.href or document.baseURI (see here) as the base location for anchor links created with the <Link> component. This change patches that bug, which we should also open as a PR against the upstream library.

Note that this may cause a full refresh in the case where ?redirect=false is set by the global shell - a separate change in the global shell should be able to prevent this.

@netlify
Copy link

netlify bot commented Apr 8, 2025

Deploy Preview for dhis2-maintenance-app-beta ready!

Name Link
🔨 Latest commit 89fe02f
🔍 Latest deploy log https://app.netlify.com/sites/dhis2-maintenance-app-beta/deploys/6808e60fbd3c7300080e9487
😎 Deploy Preview https://deploy-preview-541.maintenance-app-beta.netlify.dhis2.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@amcgee amcgee requested review from a team and Birkbjo April 9, 2025 16:02
@amcgee
Copy link
Member Author

amcgee commented Apr 9, 2025

Leaving this as draft but opening for @Birkbjo and @dhis2/platform-frontend to take a look

@amcgee
Copy link
Member Author

amcgee commented Apr 9, 2025

The downside of this fix is that it does not work in a "standalone" environment (like the netlify preview...)

@amcgee
Copy link
Member Author

amcgee commented Apr 14, 2025

Thanks @KaiVandivier for fixing standalone builds!

Looks like there's an issue with patch-package though https://www.dropbox.com/scl/fi/heegfa4utkkvp397xet8r/Screenshot-2025-04-14-at-16.18.04.png?rlkey=cvaktbn9zpzh7vh0j0qrmcq87&dl=0

@sonarqubecloud
Copy link

@KaiVandivier KaiVandivier marked this pull request as ready for review April 23, 2025 13:32
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.

3 participants