Skip to content

Commit

Permalink
fix: clear html socket view if empty content is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Nov 27, 2024
1 parent e724d90 commit 483be09
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 6 additions & 0 deletions projects/demo-playwright/tests/reset.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ test.describe('Reset', () => {
test('Correct reset value from wysiwyg', async ({page}) => {
await tuiGoto(page, '/starter-kit?placeholder=Hello');

await page.locator('tui-editor [contenteditable]').focus();
await page.waitForTimeout(300);

await expect(page.locator('tui-editor')).toHaveScreenshot('Reset-01.png');

await page.locator('button:has-text("Reset")').click();
await page.waitForTimeout(300);

await expect(page.locator('tui-editor')).toHaveScreenshot('Reset-02.png');

await page.locator('tui-editor [contenteditable]').fill('12345');
await page.waitForTimeout(300);

await expect(page.locator('tui-editor')).toHaveScreenshot('Reset-03.png');

await page.locator('button:has-text("Reset")').click();
await page.waitForTimeout(300);

await expect(page.locator('tui-editor')).toHaveScreenshot('Reset-04.png');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,9 @@ export class TuiEditorSocket {
protected readonly html = signal<SafeHtml | string | null>(null);

@Input()
public set content(content: string | null) {
if (!content) {
return;
}

public set content(content: string | null | undefined) {
const safety =
this.customSanitizer?.sanitize(SecurityContext.HTML, content) ??
this.customSanitizer?.sanitize(SecurityContext.HTML, content ?? '') ??
this.sanitizer.bypassSecurityTrustHtml(content ?? '');

this.html.set(safety);
Expand Down

0 comments on commit 483be09

Please sign in to comment.