tinymce / tinymce-blazor

Blazor integration
MIT License
45 stars 13 forks source link

Lists plugin: value not changed on text deletion #61

Closed Zilmac closed 1 year ago

Zilmac commented 1 year ago

Hi, encountered an issue where in specific scenario, editor Value is not changed on input change when it contains List elements.

How to reproduce:

  1. Setup editor with initial value that contains elements of lists e.g. <ul> <li>1234</li> </ul>
  2. With mouse select all text and delete it (this has to be the first and only action that you do)
  3. Observe persisted editors value is not changed rte-delete-list-issue

This appears to only happen on initial load when there are no other actions made yet. If you add list via editor and then delete it, it works fine.

Repo where it can be reproduced: here.

Anything that we could do here? Tried hooking up to TextChanged event and update Value manually, but it requires a lot of ugly state management (identify when it is correct to reset value on text change) which could also lead to more unexpected issues.

exalate-issue-sync[bot] commented 1 year ago

Ref: INT-3139

jscasca commented 1 year ago

Have you tried adding keyup to ModelEvents? Like <Editor ModelEvents="change input undo redo keyup" />

Zilmac commented 1 year ago

I didn't, not sure that I saw anywhere that this event needs to be explicitly specified. However, yes, it seems to fix the problem

jscasca commented 1 year ago

Sorry, I know it sounds weird. The ModelEvents property allows you to define what events bind the editor to the reactive value. By default it only includes change input undo redo because that should work most of the time. However, under weird circumstances TinyMCE doesn't always trigger a change or input when deleting content. So you have to rely on the keyup event to have the correct value. You shouldn't need to, it's weird. But until they solve that quirk we have to keep this as a workaround. Glad to hear it fixes the problem :)