diff --git a/aio/src/app/embedded/code/code-example.component.spec.ts b/aio/src/app/embedded/code/code-example.component.spec.ts index 3d1966f92b..9d2d0f6c59 100644 --- a/aio/src/app/embedded/code/code-example.component.spec.ts +++ b/aio/src/app/embedded/code/code-example.component.spec.ts @@ -65,6 +65,13 @@ describe('CodeExampleComponent', () => { expect(actual).toBe('Great Example'); }); + it('should remove the `title` attribute after initialisation', () => { + TestBed.overrideComponent(HostComponent, { + set: {template: ''}}); + createComponent(oneLineCode); + expect(codeExampleDe.nativeElement.getAttribute('title')).toEqual(null); + }); + it('should pass hideCopy to CodeComonent', () => { TestBed.overrideComponent(HostComponent, { set: {template: ''}}); diff --git a/aio/src/app/embedded/code/code-example.component.ts b/aio/src/app/embedded/code/code-example.component.ts index b35c824e85..199051260d 100644 --- a/aio/src/app/embedded/code/code-example.component.ts +++ b/aio/src/app/embedded/code/code-example.component.ts @@ -45,6 +45,8 @@ export class CodeExampleComponent implements OnInit { this.path = element.getAttribute('path') || ''; this.region = element.getAttribute('region') || ''; this.title = element.getAttribute('title') || ''; + // Now remove the title attribute to prevent unwanted tooltip popups when hovering over the code. + element.removeAttribute('title'); this.isAvoid = this.path.indexOf('.avoid.') !== -1; this.hideCopy = this.isAvoid || getBoolFromAttribute(element, ['hidecopy', 'hide-copy']);