Skip to content

Commit

Permalink
fix(module:tooptip): fix setTitle proxy to nzTitle
Browse files Browse the repository at this point in the history
close #2695
  • Loading branch information
Wendell committed Dec 27, 2018
1 parent 5c5a82d commit cbdf6dc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
7 changes: 6 additions & 1 deletion components/tooltip/nz-tooltip.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { NzToolTipComponent } from './nz-tooltip.component';

@Directive({
selector: '[nz-tooltip]',
host: {
host : {
'[class.ant-tooltip-open]': 'isTooltipOpen'
}
})
Expand Down Expand Up @@ -165,6 +165,11 @@ export class NzTooltipDirective implements AfterViewInit, OnChanges, OnInit, OnD
this.updateCompValue(key, change.currentValue);
}
});

if (changes.setTitle) {
this.nzTitle = changes.setTitle.currentValue;
this.updateCompValue('nzTitle', changes.setTitle.currentValue);
}
}
}
}
14 changes: 13 additions & 1 deletion components/tooltip/nz-tooltip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,24 @@ describe('NzTooltip', () => {
expect(triggerElement.nextSibling.tagName).toBe('BUTTON');
}));

it('should set `setTitle` proxy to `nzTitle`', () => {
fixture.detectChanges();
const tooltipComponent = (component.titleStringNzTooltipDirective as any).tooltip as NzToolTipComponent; // tslint:disable-line:no-any
expect(tooltipComponent.nzTitle).toBe('title-string');

component.title = 'changed!';
fixture.detectChanges();
expect(tooltipComponent.nzTitle).toBe('changed!');
});

});

});

@Component({
selector: 'nz-tooltip-test-new',
template: `
<a #titleString nz-tooltip nzTitle="title-string" nzTrigger="hover" nzPlacement="topLeft" nzOverlayClassName="testClass" [nzOverlayStyle]="{color:'#000'}"
<a #titleString nz-tooltip [nzTitle]="title" nzTrigger="hover" nzPlacement="topLeft" nzOverlayClassName="testClass" [nzOverlayStyle]="{color:'#000'}"
[nzMouseEnterDelay]="0.15" [nzMouseLeaveDelay]="0.1">Show</a>
<a #titleTemplate nz-tooltip [nzTitle]="template">Show</a>
<ng-template #template>
Expand All @@ -266,6 +276,8 @@ export class NzTooltipTestNewComponent {
@ViewChild('titleTemplate', { read: NzTooltipDirective }) titleTemplateNzTooltipDirective: NzTooltipDirective;
@ViewChild('inBtnGroup') inBtnGroup: ElementRef;

title = 'title-string';

}

@Component({
Expand Down

0 comments on commit cbdf6dc

Please sign in to comment.