Skip to content

Commit

Permalink
Fixed countrySettings undefined issue (carbon-design-system#11559)
Browse files Browse the repository at this point in the history
### Related Ticket(s)

[Noitce & Choice w3 Publisher](https://w3.ibm.com/w3publisher/urx/notice-and-choice-v23)

### Description

Notice & Choice is a legally required component to create a form where IBM collects its customer information.
This section shows the specific product's legal links, terms, and conditions. Along with this, it collects users' consent regarding communication preferences.

### Changelog

**New**

**Changed**

-  Fixed bug country setting undefined issue.

**Removed**

<!-- 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
deathcave authored Feb 28, 2024
1 parent eee2c73 commit 9561716
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class NoticeChoice extends StableSelectorMixin(LitElement) {
termsConditionLink = html``;

@property({ type: Boolean, attribute: 'enable-all-opt-in' })
enableAllOptIn;
enableAllOptIn = false;

@property({ attribute: 'default-values' })
defaultValues = {};
Expand Down Expand Up @@ -167,7 +167,14 @@ class NoticeChoice extends StableSelectorMixin(LitElement) {
} else if (supportedLanguages(language)) {
defaultLanguage = supportedLanguages(language);
}

loadSettings(
(countryPreferencesSettings) => {
this.countrySettings = countryPreferencesSettings;
},
() => {
this.countrySettings = this.defaultLoadSettings();
}
);
loadContent(
defaultLanguage,
(ncData) => {
Expand All @@ -179,14 +186,6 @@ class NoticeChoice extends StableSelectorMixin(LitElement) {
this.defaultLoadContent();
}
);
loadSettings(
(countryPreferencesSettings) => {
this.countrySettings = countryPreferencesSettings;
},
() => {
this.defaultLoadSettings();
}
);
}
setDefaultSelections() {
if (!this.enableAllOptIn && this.checkboxes) {
Expand Down Expand Up @@ -308,7 +307,10 @@ class NoticeChoice extends StableSelectorMixin(LitElement) {
break;
}
case 'enable-all-opt-in':
this.setDefaultSelections();
if (oldVal !== newVal) {
this.enableAllOptIn = JSON.parse(newVal);
this.setDefaultSelections();
}
break;
case 'hide-error-message': {
if (oldVal !== newVal) {
Expand Down

0 comments on commit 9561716

Please sign in to comment.