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

🐞 - TuiEditor: the value in the component is incorrectly updated when it is passed as an empty string using formControl #1522

Closed
algashev123 opened this issue Oct 9, 2024 · 3 comments · Fixed by #1558
Labels
bug Something isn't working P1 This issue has high priority

Comments

@algashev123
Copy link

Reproduction url

https://taiga-family.github.io/editor/starter-kit?ngModel=&placeholder=Test

Description

An empty string is incorrectly processed by the TuiEditor component. Playback Steps:

  1. Open the showcase at the specified link;
  2. In the ngModel: Example pass HTML code input, delete the value through the cross;
  3. Enter something into the Editor component;
  4. Repeat step 2;
  5. Look at the result.

Expected behavior:
The component has cleared, there is no value in it and the placeholder is visible.

Current result:
The text in the input is not cleared, the placeholder is layered on the text
Снимок экрана 2024-10-09 в 17 06 48

Taiga UI version

4.15.0

Browser Used

Chrome

OS Used

macOS

@algashev123 algashev123 added bug Something isn't working state: need triage state need triage labels Oct 9, 2024
@andreyjamer
Copy link

andreyjamer commented Oct 24, 2024

I'm observing the same issue. Looks like it is caused by the usage of firstInitialValue in editor.component.ts

this.firstInitialValue = processed ?? '';

The property is set on the component initialization and passed to the tuiTiptapEditor directive

If component has any value on initialization, then the editor will display it. It is possible to reset the content only once through external formControl. Other attempts will not clean the editor.
If the exampleText property is set, then the content will overlap it.

Steps to reproduce are the following:

  1. Take this example: https://taiga-family.github.io/editor/starter-kit
  2. Add [exampleText]="'Input your sentence here'" to the <tui-editor ...> component
  3. Add button below the editor: <button type="button" (click)="control.setValue('')">reset</button>
  4. Open the page and press reset button. Editor will be cleaned and Input your sentence here will be displayed as placeholder
  5. Input 12345 in the editor. The placeholder will disappear, the text will be displayed normally.
  6. Press reset button
  7. 12345 will no disappear, but Input your sentence here will be displayed below it.
    Image

Another issue probably related to it is that tui-editor-socket is also do not update the value on formControl cleanup. It is easy to check in the same example. HTML: block below the editor always has a value before cleanup. And it doesn't matter if reset button was pressed or for example user pressed CTRL+A in the editor and DELETE after it.

@konverso-aakulov
Copy link

Hello! Is there any update on this issue?

@splincode
Copy link
Member

I'll take this issue on Monday

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1 This issue has high priority
Projects
None yet
4 participants