@@ -547,6 +547,60 @@ describe('KbqInlineEdit', () => {
547547 expect ( overlay ?. classList . contains ( 'test-custom-inline-edit-panel' ) ) . toBeTruthy ( ) ;
548548 } ) ;
549549 } ) ;
550+
551+ describe ( 'validationTooltip' , ( ) => {
552+ const openEditAndInvalidate = ( fixture : ComponentFixture < TestWithDynamicValidationTooltip > ) => {
553+ const { componentInstance, debugElement } = fixture ;
554+ const inlineEditDebugElement = getInlineEditDebugElement ( debugElement ) ;
555+
556+ inlineEditDebugElement . nativeElement . click ( ) ;
557+ fixture . detectChanges ( ) ;
558+
559+ getOverlayElement ( ) ! . querySelector < HTMLElement > ( '.kbq-textarea' ) ?. focus ( ) ;
560+ componentInstance . control . markAsTouched ( ) ;
561+ componentInstance . control . updateValueAndValidity ( ) ;
562+ fixture . detectChanges ( ) ;
563+
564+ return inlineEditDebugElement ;
565+ } ;
566+
567+ const clickSave = ( ) => {
568+ (
569+ document . querySelector ( `${ componentCssClasses . panel } ${ componentCssClasses . terminalButtons } ` ) !
570+ . firstElementChild as HTMLButtonElement
571+ ) . click ( ) ;
572+ } ;
573+
574+ it ( 'should not show tooltip when empty string is passed and control is invalid' , ( ) => {
575+ const fixture = setup ( TestWithDynamicValidationTooltip ) ;
576+ const { componentInstance } = fixture ;
577+
578+ componentInstance . validationTooltip . set ( '' ) ;
579+
580+ const inlineEditDebugElement = openEditAndInvalidate ( fixture ) ;
581+ const tooltipTrigger = ( inlineEditDebugElement . componentInstance as any ) . tooltipTrigger ( ) ;
582+ const showSpy = jest . spyOn ( tooltipTrigger , 'show' ) ;
583+
584+ clickSave ( ) ;
585+
586+ expect ( showSpy ) . not . toHaveBeenCalled ( ) ;
587+ } ) ;
588+
589+ it ( 'should show tooltip when message is provided and control is invalid' , ( ) => {
590+ const fixture = setup ( TestWithDynamicValidationTooltip ) ;
591+ const { componentInstance } = fixture ;
592+
593+ componentInstance . validationTooltip . set ( 'Required field' ) ;
594+
595+ const inlineEditDebugElement = openEditAndInvalidate ( fixture ) ;
596+ const tooltipTrigger = ( inlineEditDebugElement . componentInstance as any ) . tooltipTrigger ( ) ;
597+ const showSpy = jest . spyOn ( tooltipTrigger , 'show' ) ;
598+
599+ clickSave ( ) ;
600+
601+ expect ( showSpy ) . toHaveBeenCalled ( ) ;
602+ } ) ;
603+ } ) ;
550604} ) ;
551605
552606@Directive ( {
@@ -909,6 +963,26 @@ export class TestWithSelect extends BaseTestComponent {
909963 cancel = jest . fn ( ) ;
910964}
911965
966+ @Component ( {
967+ selector : 'name' ,
968+ imports : [ ReactiveFormsModule , KbqFormFieldModule , KbqInlineEditModule , KbqTextareaModule ] ,
969+ template : `
970+ <kbq-inline-edit showActions [validationTooltip]="validationTooltip()" (saved)="update()">
971+ <div kbqInlineEditViewMode>{{ control.value }}</div>
972+ <kbq-form-field kbqInlineEditEditMode>
973+ <textarea kbqTextarea [formControl]="control"></textarea>
974+ </kbq-form-field>
975+ </kbq-inline-edit>
976+ ` ,
977+ providers : [ kbqDisableLegacyValidationDirectiveProvider ( ) ]
978+ } )
979+ export class TestWithDynamicValidationTooltip {
980+ readonly control = new FormControl ( '' , Validators . required ) ;
981+ readonly validationTooltip = signal ( '' ) ;
982+
983+ update ( ) { }
984+ }
985+
912986@Component ( {
913987 selector : 'name' ,
914988 imports : [
0 commit comments