Skip to content

Commit

Permalink
fix(core): fix custom hint (#9776)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirpotekhin authored Nov 20, 2024
1 parent b97dcd4 commit ae83d2d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
9 changes: 7 additions & 2 deletions projects/core/directives/hint/hint-unstyled.component.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type {WritableSignal} from '@angular/core';
import {
ChangeDetectionStrategy,
Component,
Expand All @@ -8,6 +9,7 @@ import {
import type {TuiContext} from '@taiga-ui/cdk/types';
import {tuiParentAnimation} from '@taiga-ui/core/animations';
import type {TuiPortalItem} from '@taiga-ui/core/types';
import type {PolymorpheusContent} from '@taiga-ui/polymorpheus';
import {
injectContext,
PolymorpheusComponent,
Expand All @@ -19,13 +21,16 @@ import {TuiHintDirective} from './hint.directive';
@Component({
standalone: true,
imports: [PolymorpheusOutlet],
template: '<ng-container *polymorpheusOutlet="context.$implicit.content" />',
template: '<ng-container *polymorpheusOutlet="context.$implicit.content()" />',
changeDetection: ChangeDetectionStrategy.OnPush,
animations: [tuiParentAnimation],
host: {'[@tuiParentAnimation]': ''},
})
export class TuiHintUnstyledComponent {
protected readonly context = injectContext<TuiContext<TuiPortalItem>>();
protected readonly context =
injectContext<
TuiContext<TuiPortalItem & {content: WritableSignal<PolymorpheusContent>}>
>();
}

@Directive({
Expand Down
9 changes: 9 additions & 0 deletions projects/demo-playwright/tests/core/hint/hint.pw.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,13 @@ test.describe('TuiHint', () => {

await expect(page).toHaveScreenshot('06-hint-direction__left.png');
});

test('TuiHint customizing works', async ({page}) => {
await tuiGoto(page, DemoRoute.Hint);
const example = new TuiDocumentationPagePO(page).getExample('#customizing');

await example.locator('tui-avatar').hover();

await expect(example).toHaveScreenshot('07-hint.png');
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<tui-avatar
size="l"
tuiHint
tuiHintDirection="right"
[style.background]="'❤' | tuiAutoColor"
>
Expand Down

0 comments on commit ae83d2d

Please sign in to comment.