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() binder.asRequired fail #8766

Open
sveinnetnordic opened this issue Mar 5, 2025 · 1 comment
Open

RichTextEditor() binder.asRequired fail #8766

sveinnetnordic opened this issue Mar 5, 2025 · 1 comment
Labels
bug Something isn't working Impact: Low known issue Known issue that can't be easily fixed Severity: Major vaadin-rich-text-editor workaround There is a workaround in the comments.

Comments

@sveinnetnordic
Copy link

sveinnetnordic commented Mar 5, 2025

Description

Works initial if empty. When text is removed it does not work.

See: #8453

Expected outcome

Should validate

Minimal reproducible example

Add text, and remove

binder.forField(contentRte)
    .asRequired(translate("entity.validation.required")) //FAILS, See: https://github.com/vaadin/web-components/issues/8453
    .withValidator({ !contentRte.isEmpty }, translate("entity.validation.required"))
    .withStatusLabel(contentRteStatusLabel)
    .bind({ it.admissionEmailDTO.content }, { o, v -> o.admissionEmailDTO.content = v })

Steps to reproduce

see above

Environment

Hilla: 24.7.0.beta1
Flow: 24.7.0.beta1
Vaadin: 24.7.0.beta1
Spring Boot: 3.4.1
Spring: 6.2.1
Spring Security: ☑
Spring Data JPA: ☑
Copilot: 24.7.0.beta1
Frontend Hotswap: Disabled, using pre-built bundle
OS: amd64 Windows 11 10.0
Java: JetBrains s.r.o. 21.0.5
Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Java Hotswap: Java Hotswap is enabled
IDE Plugin: 1.4.8 IntelliJ

Browsers

No response

@sissbruecker
Copy link
Contributor

Currently this is not trivial to solve with how Binder's asRequired works. I've filed in issue in the Flow repo to enable this use-case: vaadin/flow#21106. The documentation now also contains a note about this problem and how to work around it: vaadin/docs#4170.

The workaround for now is to provide a custom validator to asRequired:

binder.forField(richTextEditor)
    .asRequired(Validator.from(value -> !richTextEditor.isEmpty(), "Required"));

@sissbruecker sissbruecker added known issue Known issue that can't be easily fixed workaround There is a workaround in the comments. labels Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Impact: Low known issue Known issue that can't be easily fixed Severity: Major vaadin-rich-text-editor workaround There is a workaround in the comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants