Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clear html socket view if empty content is passed #1612

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading