-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(masthead): container should respect user's L0 data (#11420)
### Related Ticket(s) Previously fixed in #10986, but that was unwittingly wiped away by #11252 ### Description Fixes an issue where `<c4d-masthead-container>` wipes away user-set L0 data with translations fetched from an API. This PR takes a different approach from the original fix. The root problem is that the masthead container isn't aware of any `l0Data` passed in before setting that property with translation data. I figured we can make the container a little smarter and handle the logic internally rather than adding another property to the masthead composite and complicating the public API. In order to facilitate this, I needed the `ConnectMixin` to pass a reference to the class instance into the `mapStateToProps` function it expects classes to define. This empowers the container to first check if it has L0 data before resorting to the translations API data. As a result, users can reliably set the `l0Data` property on either `<c4d-masthead-container>` or `<c4d-masthead-composite>` and expect the same outcome. ### Changelog **New** - `ConnectMixin` passes a class instance reference as an argument in the `mapStateToProps` function. **Changed** - `<c4d-masthead-container>` will prefer using L0 data passed by user before resorting to automatically fetched translation data. <!-- React and Web Component deploy previews are enabled by default. --> <!-- To enable additional available deploy previews, apply the following --> <!-- labels for the corresponding package: --> <!-- *** "test: e2e": Codesandbox examples and e2e integration tests --> <!-- *** "package: services": Services --> <!-- *** "package: utilities": Utilities --> <!-- *** "RTL": React / Web Components (RTL) --> <!-- *** "feature flag": React / Web Components (experimental) -->
- Loading branch information
Showing
4 changed files
with
34 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters