Skip to content

Add FidesLocaleUpdated event to monitor locale changes and improve documentation#7234

Merged
gilluminate merged 10 commits intomainfrom
gill/ENG-1780/update-getmodallinkvariable-to-honor-trigger-link
Jan 27, 2026
Merged

Add FidesLocaleUpdated event to monitor locale changes and improve documentation#7234
gilluminate merged 10 commits intomainfrom
gill/ENG-1780/update-getmodallinkvariable-to-honor-trigger-link

Conversation

@gilluminate
Copy link
Contributor

@gilluminate gilluminate commented Jan 15, 2026

Ticket: ENG-1780

Description

Previously, the recommended pattern would result in the modal link label not updating when users changed their language preference. Adds FidesLocaleUpdated event to support this. Updated getModalLinkLabel() documentation and implementation to properly handle locale changes.

Even though "fides-modal-link" has always been our default value for modalLinkID, it never showed up that way in Fides.options. This PR also updates the way we set that default to be more accessible to customers.

Several other race condition fixes to ensure locale is respected during and after page load.

Code Changes

  • Added FidesLocaleUpdated event that fires during pageload and when locale changes
  • Updated LanguageSelector component to dispatch locale change events
  • Improved documentation with correct event listener pattern
  • Changed modalLinkId type from string | null to string with default value
  • Updated demo page to use the new event-driven pattern

Steps to Confirm

  1. Set up a US, a TCF, and a headless experience
  2. Ensure each experience has a translation set for "Trigger link label" (eg. in the german language use "Einstellungen verwalten")
  3. In Chrome dev tools, go to Kabab menu -> More Tools -> Sensors and Change location to get the locale set in the browser (eg. Berlin to get the de-DE locale set)
  4. Load the fides-js demo page for each experience's location (eg. http://localhost:3001/fides-js-demo.html?geolocation=eea for TCF, etc.)
  5. Verify the modal link label displays the translated value on page load
  6. Change the language using the language selector in the banner and/or modal
  7. Verify the modal link label updates to match the selected language

@vercel
Copy link
Contributor

vercel bot commented Jan 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Review Updated (UTC)
fides-plus-nightly Ignored Ignored Preview Jan 26, 2026 5:39pm
fides-privacy-center Ignored Ignored Jan 26, 2026 5:39pm

Request Review

@gilluminate gilluminate changed the title Update getModalLinkLabel to honor locale changes and improve documentation Add FidesLocaleUpdated event to monitor locale changes and improve documentation Jan 15, 2026
@gilluminate gilluminate force-pushed the gill/ENG-1780/update-getmodallinkvariable-to-honor-trigger-link branch from 0458ed8 to 0f19917 Compare January 15, 2026 23:11
@gilluminate gilluminate requested a review from tvandort January 15, 2026 23:12
@gilluminate gilluminate force-pushed the gill/ENG-1780/update-getmodallinkvariable-to-honor-trigger-link branch 2 times, most recently from 3d43f5b to 3539ba4 Compare January 16, 2026 22:06
window.Fides.locale = bestLocale;
setFidesGlobal(window.Fides as InitializedFidesGlobal);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This got missed when we first implemented the min/full experience split on TCF.

@gilluminate gilluminate force-pushed the gill/ENG-1780/update-getmodallinkvariable-to-honor-trigger-link branch from 5de2f2e to c1324ab Compare January 16, 2026 22:48
@gilluminate gilluminate marked this pull request as ready for review January 17, 2026 00:07
@gilluminate gilluminate requested a review from a team as a code owner January 17, 2026 00:07
@gilluminate gilluminate requested review from jpople and removed request for a team January 17, 2026 00:07
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 17, 2026

Greptile Summary

This PR adds a new FidesLocaleUpdated event that fires when users change their language preference, solving the issue where modal link labels wouldn't update dynamically. The implementation also improves the modalLinkId default value handling by changing it from string | null to string with a guaranteed default of "fides-modal-link", making it more accessible to customers in Fides.options.

Key changes:

  • Added FidesLocaleUpdated event with dispatchLocaleEvent() function
  • Updated language selector to dispatch locale events when changed
  • Improved documentation with correct event-driven pattern for updating modal links
  • Changed modalLinkId type to string with DEFAULT_MODAL_LINK_ID constant
  • Updated demo page to demonstrate the new event listener pattern
  • Fixed locale event dispatching for both regular and TCF overlays as well as headless mode

Confidence Score: 5/5

  • This PR is safe to merge with no issues found
  • The implementation is well-designed with proper event dispatching, comprehensive documentation, and consistent handling across all code paths (regular overlay, TCF overlay, and headless mode). The type change from string | null to string improves type safety and makes the default value more discoverable. All changes are backwards compatible and follow existing patterns in the codebase.
  • No files require special attention

Important Files Changed

Filename Overview
clients/fides-js/src/lib/events.ts Added FidesLocaleUpdated event and dispatchLocaleEvent function to notify listeners when locale changes
clients/fides-js/src/lib/i18n/i18n-context.tsx Updated setCurrentLocale callback to dispatch locale change events when language is changed
clients/fides-js/src/lib/consent-types.ts Changed modalLinkId type from `string
clients/fides-js/src/lib/initialize.ts Added dispatchLocaleEvent call for headless component to ensure locale event fires when modal link is found
clients/privacy-center/public/fides-js-demo.html Updated demo to use event-driven pattern with FidesLocaleUpdated listener instead of manual polling
clients/fides-js/src/docs/fides-event.ts Added comprehensive documentation for new FidesLocaleEvent interface

@gilluminate gilluminate force-pushed the gill/ENG-1780/update-getmodallinkvariable-to-honor-trigger-link branch from 587d540 to 61f954d Compare January 26, 2026 17:39
@gilluminate gilluminate requested review from tvandort and removed request for tvandort January 26, 2026 17:40
Copy link
Contributor

@jpople jpople left a comment

Choose a reason for hiding this comment

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

Tested locally, link label is correct based on browser location and updates as expected. Nice work!

@gilluminate gilluminate added this pull request to the merge queue Jan 27, 2026
Merged via the queue into main with commit 8d35ff9 Jan 27, 2026
45 of 46 checks passed
@gilluminate gilluminate deleted the gill/ENG-1780/update-getmodallinkvariable-to-honor-trigger-link branch January 27, 2026 23:38
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