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

RichTextEditor().asHtml().isEmpty fail when contents is removed #8453

Open
sveinnetnordic opened this issue Jan 8, 2025 · 3 comments
Open

Comments

@sveinnetnordic
Copy link

sveinnetnordic commented Jan 8, 2025

Description

When contents in RichTextEditor is removed .asHtml().value = "<p><br></p>". .asHtml().isEmpty returns false, so cannot test if contents is empty

Expected outcome

.asHtml().isEmpty should return true when everything is deleted in the editor

Minimal reproducible example

Add contents an remove it, test .asHtml().isEmpty

Steps to reproduce

.asHtml().isEmpty

Environment

Hilla: 24.6.0
Flow: 24.6.0
Vaadin: 24.6.0
Copilot: 24.6.0
Frontend Hotswap: Disabled, using pre-built bundle
OS: amd64 Windows 11 10.0
Java: JetBrains s.r.o. 21.0.3
Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Java Hotswap: Hotswap is partially enabled
IDE Plugin: 1.4.3 IntelliJ

Browsers

No response

@sveinnetnordic
Copy link
Author

As a workaround .asDelta().isEmpty works, but first time the contents is removed in RTE. Running a dummy rte.asDelta() fix this. Seems like another bug?
image

@sissbruecker
Copy link
Contributor

asDelta intentionally clears the component value, probably because the delta value is not synchronized with the HTML value unless asDelta has been called previously. It would thus always be empty even if there is an HTML value. So mixing asHtml and asDelta is not quite supported by the component.

@sveinnetnordic
Copy link
Author

asDelta intentionally clears the component value, probably because the delta value is not synchronized with the HTML value unless asDelta has been called previously. It would thus always be empty even if there is an HTML value. So mixing asHtml and asDelta is not quite supported by the component.

OK, this is only a work around for the bug. Could test for "<p><br></p>", but feels that is even more dirty workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants