diff --git a/CHANGELOG.md b/CHANGELOG.md index beaa53643f..fd6b8f3b3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Our versioning strategy is as follows: * `[templates/nextjs]` `[templates/react]` `[templates/angular]` `[templates/vue]` Fixed an issue when environment variable is undefined (not present in .env), that produced an "undefined" value in generated config file ([#1875](https://github.com/Sitecore/jss/pull/1875)) * `[templates/nextjs]` Fix embedded personalization not rendering correctly after navigation through router links. ([#1911](https://github.com/Sitecore/jss/pull/1911)) * `[template/angular]` Prevent client-side dictionary API call when SSR data is available ([#1930](https://github.com/Sitecore/jss/pull/1930)) ([#1932](https://github.com/Sitecore/jss/pull/1932)) +* `[sitecore-jss-angular]` Fix default empty field components to not render the unwanted wrapping tags ([#1937](https://github.com/Sitecore/jss/pull/1937)) ### 🎉 New Features & Improvements diff --git a/packages/sitecore-jss-angular/src/components/base-field.directive.spec.ts b/packages/sitecore-jss-angular/src/components/base-field.directive.spec.ts index 77d85471c5..144729a201 100644 --- a/packages/sitecore-jss-angular/src/components/base-field.directive.spec.ts +++ b/packages/sitecore-jss-angular/src/components/base-field.directive.spec.ts @@ -130,7 +130,9 @@ describe('', () => { fixture.detectChanges(); const rendered = de.nativeElement.innerHTML; - expect(rendered).toContain('[No text in field]'); + expect(rendered).toContain( + '[No text in field]' + ); }); it('should render custom empty editing template if provided', () => { @@ -199,7 +201,9 @@ describe('', () => { comp.field = field; fixture.detectChanges(); - const fieldValue = de.query(By.css('sc-default-empty-text-field-editing-placeholder')); + const fieldValue = de.query( + By.css('span[sc-default-empty-text-field-editing-placeholder]') + ); const metadataOpenTag = fieldValue.nativeElement.previousElementSibling; const metadataCloseTag = fieldValue.nativeElement.nextElementSibling; diff --git a/packages/sitecore-jss-angular/src/components/date.directive.spec.ts b/packages/sitecore-jss-angular/src/components/date.directive.spec.ts index 189f2ef8c9..1bc986f2f7 100644 --- a/packages/sitecore-jss-angular/src/components/date.directive.spec.ts +++ b/packages/sitecore-jss-angular/src/components/date.directive.spec.ts @@ -160,7 +160,9 @@ describe('', () => { fixture.detectChanges(); const rendered = de.nativeElement.innerHTML; - expect(rendered).toContain('[No text in field]'); + expect(rendered).toContain( + '[No text in field]' + ); }); it('should render default empty field component when field value is the default empty date value', () => { @@ -172,7 +174,9 @@ describe('', () => { fixture.detectChanges(); const rendered = de.nativeElement.innerHTML; - expect(rendered).toContain('[No text in field]'); + expect(rendered).toContain( + '[No text in field]' + ); }); it('should render custom empty field component when provided, when field value is empty', () => { @@ -256,7 +260,9 @@ describe('', () => { comp.field = field; fixture.detectChanges(); - const fieldValue = de.query(By.css('sc-default-empty-text-field-editing-placeholder')); + const fieldValue = de.query( + By.css('span[sc-default-empty-text-field-editing-placeholder]') + ); const metadataOpenTag = fieldValue.nativeElement.previousElementSibling; const metadataCloseTag = fieldValue.nativeElement.nextElementSibling; diff --git a/packages/sitecore-jss-angular/src/components/default-empty-image-field-editing-placeholder.component.ts b/packages/sitecore-jss-angular/src/components/default-empty-image-field-editing-placeholder.component.ts index 660d7ef8aa..b06fcec2f6 100644 --- a/packages/sitecore-jss-angular/src/components/default-empty-image-field-editing-placeholder.component.ts +++ b/packages/sitecore-jss-angular/src/components/default-empty-image-field-editing-placeholder.component.ts @@ -4,7 +4,7 @@ import { Component } from '@angular/core'; * Default component that will be rendered in pages when image field is empty. */ @Component({ - selector: 'sc-default-empty-image-field-editing-placeholder', + selector: '[sc-default-empty-image-field-editing-placeholder]', template: ` [No text in field]', + selector: '[sc-default-empty-text-field-editing-placeholder]', + template: '[No text in field]', }) export class DefaultEmptyFieldEditingComponent {} diff --git a/packages/sitecore-jss-angular/src/components/generic-link.directive.spec.ts b/packages/sitecore-jss-angular/src/components/generic-link.directive.spec.ts index ba972213e7..76f008d1bb 100644 --- a/packages/sitecore-jss-angular/src/components/generic-link.directive.spec.ts +++ b/packages/sitecore-jss-angular/src/components/generic-link.directive.spec.ts @@ -27,7 +27,8 @@ class TestComponent { const emptyLinkFieldEditingTemplateId = 'emptyLinkFieldEditingTemplate'; const emptyLinkFieldEditingTemplate = '[This is a *custom* empty field template]'; -const emptyLinkFieldEditingTemplateDefaultTestString = '[No text in field]'; +const emptyLinkFieldEditingTemplateDefaultTestString = + '[No text in field]'; @Component({ selector: 'test-empty-template-generic-link', diff --git a/packages/sitecore-jss-angular/src/components/image.directive.spec.ts b/packages/sitecore-jss-angular/src/components/image.directive.spec.ts index 154ea0c4f6..4ff50438b5 100644 --- a/packages/sitecore-jss-angular/src/components/image.directive.spec.ts +++ b/packages/sitecore-jss-angular/src/components/image.directive.spec.ts @@ -512,7 +512,7 @@ describe('', () => { comp.field = field; fixture.detectChanges(); - const fieldValue = de.query(By.css('sc-default-empty-image-field-editing-placeholder')); + const fieldValue = de.query(By.css('[sc-default-empty-image-field-editing-placeholder]')); const metadataOpenTag = fieldValue.nativeElement.previousElementSibling; const metadataCloseTag = fieldValue.nativeElement.nextElementSibling; diff --git a/packages/sitecore-jss-angular/src/components/link.directive.spec.ts b/packages/sitecore-jss-angular/src/components/link.directive.spec.ts index ff8ada6407..8ef3bc4ab7 100644 --- a/packages/sitecore-jss-angular/src/components/link.directive.spec.ts +++ b/packages/sitecore-jss-angular/src/components/link.directive.spec.ts @@ -20,7 +20,8 @@ class TestComponent { const emptyLinkFieldEditingTemplateId = 'emptyLinkFieldEditingTemplate'; const emptyLinkFieldEditingTemplate = '[This is a *custom* empty field template]'; -const emptyLinkFieldEditingTemplateDefaultTestString = '[No text in field]'; +const emptyLinkFieldEditingTemplateDefaultTestString = + '[No text in field]'; @Component({ selector: 'test-empty-template-link', @@ -389,7 +390,9 @@ describe('', () => { comp.field = field; fixture.detectChanges(); - const fieldValue = de.query(By.css('sc-default-empty-text-field-editing-placeholder')); + const fieldValue = de.query( + By.css('span[sc-default-empty-text-field-editing-placeholder]') + ); const metadataOpenTag = fieldValue.nativeElement.previousElementSibling; const metadataCloseTag = fieldValue.nativeElement.nextElementSibling; @@ -740,7 +743,9 @@ describe('children', () => { comp.field = field; fixture.detectChanges(); - const fieldValue = de.query(By.css('sc-default-empty-text-field-editing-placeholder')); + const fieldValue = de.query( + By.css('span[sc-default-empty-text-field-editing-placeholder]') + ); const metadataOpenTag = fieldValue.nativeElement.previousElementSibling; const metadataCloseTag = fieldValue.nativeElement.nextElementSibling; diff --git a/packages/sitecore-jss-angular/src/components/rich-text.directive.spec.ts b/packages/sitecore-jss-angular/src/components/rich-text.directive.spec.ts index 2d53280cac..2537811147 100644 --- a/packages/sitecore-jss-angular/src/components/rich-text.directive.spec.ts +++ b/packages/sitecore-jss-angular/src/components/rich-text.directive.spec.ts @@ -172,7 +172,9 @@ describe('
', () => { fixture.detectChanges(); const rendered = de.nativeElement.innerHTML; - expect(rendered).toContain('[No text in field]'); + expect(rendered).toContain( + '[No text in field]' + ); }); it('should render custom empty field component when provided, when field value is empty', () => { @@ -238,7 +240,9 @@ describe('
', () => { comp.field = field; fixture.detectChanges(); - const fieldValue = de.query(By.css('sc-default-empty-text-field-editing-placeholder')); + const fieldValue = de.query( + By.css('span[sc-default-empty-text-field-editing-placeholder]') + ); const metadataOpenTag = fieldValue.nativeElement.previousElementSibling; const metadataCloseTag = fieldValue.nativeElement.nextElementSibling; diff --git a/packages/sitecore-jss-angular/src/components/router-link.directive.spec.ts b/packages/sitecore-jss-angular/src/components/router-link.directive.spec.ts index cfb3d7e803..3c7e43f70a 100644 --- a/packages/sitecore-jss-angular/src/components/router-link.directive.spec.ts +++ b/packages/sitecore-jss-angular/src/components/router-link.directive.spec.ts @@ -25,7 +25,8 @@ class TestComponent { const emptyLinkFieldEditingTemplateId = 'emptyLinkFieldEditingTemplate'; const emptyLinkFieldEditingTemplate = '[This is a *custom* empty field template]'; -const emptyLinkFieldEditingTemplateDefaultTestString = '[No text in field]'; +const emptyLinkFieldEditingTemplateDefaultTestString = + '[No text in field]'; @Component({ selector: 'test-empty-template-router-link', diff --git a/packages/sitecore-jss-angular/src/components/text.directive.spec.ts b/packages/sitecore-jss-angular/src/components/text.directive.spec.ts index 43b2083876..e1d39ef245 100644 --- a/packages/sitecore-jss-angular/src/components/text.directive.spec.ts +++ b/packages/sitecore-jss-angular/src/components/text.directive.spec.ts @@ -215,7 +215,9 @@ describe('', () => { fixture.detectChanges(); const rendered = de.nativeElement.innerHTML; - expect(rendered).toContain('[No text in field]'); + expect(rendered).toContain( + '[No text in field]' + ); }); it('should render custom empty field component when provided, when field value is empty', () => { @@ -281,7 +283,9 @@ describe('', () => { comp.field = field; fixture.detectChanges(); - const fieldValue = de.query(By.css('sc-default-empty-text-field-editing-placeholder')); + const fieldValue = de.query( + By.css('span[sc-default-empty-text-field-editing-placeholder]') + ); const metadataOpenTag = fieldValue.nativeElement.previousElementSibling; const metadataCloseTag = fieldValue.nativeElement.nextElementSibling;