Skip to content

Conversation

@gilluminate
Copy link
Contributor

@gilluminate gilluminate commented Jan 15, 2026

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.

Code Changes

  • Added FidesLocaleUpdated event that fires 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

Ticket

ENG-1780

Steps to Confirm

  1. Load the fides-js demo page at http://localhost:3001/fides-js-demo.html
  2. Verify the modal link label displays correctly on page load
  3. Change the language using the language selector
  4. Verify the modal link label updates to match the selected language
  5. Check browser console for FidesLocaleUpdated event logs

@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 16, 2026 11:44pm
fides-privacy-center Ignored Ignored Jan 16, 2026 11:44pm

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 from 40c3980 to 3d43f5b Compare January 16, 2026 22:05
@gilluminate gilluminate force-pushed the gill/ENG-1780/update-getmodallinkvariable-to-honor-trigger-link branch from 3d43f5b to 3539ba4 Compare January 16, 2026 22:06
Comment on lines +278 to +279
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

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