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

Add HasRequired to control setRequired in components #386

Closed
koendecock opened this issue Aug 31, 2022 · 5 comments · Fixed by #394
Closed

Add HasRequired to control setRequired in components #386

koendecock opened this issue Aug 31, 2022 · 5 comments · Fixed by #394
Assignees
Labels
api All things related with adding, removing and modifying public API. enhancement New feature or request

Comments

@koendecock
Copy link

I need to put the attribute 'required' on the SuperBigDecimal field. For the other fields in my application I simply do field.getElement().setProperty("required", true); . This gives the fields the appropriate styling a required field needs to have. This doesn't work on SuperBigDecimal because it encapsulates a SuperTextField and the attribute needs to be put on the SuperTextField in order for the required styling to appear. The solution would be to have a getter getField() on AbstractSuperNumberField so that I can do superBigDecimalField.getField().getElement().setProperty("required", true);

@vaadin-miki vaadin-miki changed the title Possibility to set property on SuperBigDecimalField Allow setting element properties on number fields Aug 31, 2022
@vaadin-miki vaadin-miki self-assigned this Aug 31, 2022
@vaadin-miki vaadin-miki added enhancement New feature or request api All things related with adding, removing and modifying public API. labels Aug 31, 2022
@vaadin-miki vaadin-miki added this to the Backlog milestone Aug 31, 2022
@vaadin-miki vaadin-miki changed the title Allow setting element properties on number fields Number fields should support setRequired() Aug 31, 2022
@vaadin-miki
Copy link
Owner

Hi @koendecock and thanks for using my components. Indeed, the properties api is missing, as getElement() will return the element of the custom field, rather than the inner text field. As is missing setRequired, which is present on the TextField, but not on the number field. I think that would be the simplest solution, so I will add that in the next release - the method simply calls getElement().setProperty(). Most likely it will end up as an interface added to all fields in the pack.

As a side note, I am not a huge fan of exposing the field to the world, as that would allow users to freely modify e.g. the regexp underneath, leading to weird errors.

@koendecock
Copy link
Author

koendecock commented Aug 31, 2022

Hi @vaadin-miki, great. Adding setRequired will suit my needs. Any idea when the next release will be available? Thanks.

@vaadin-miki
Copy link
Owner

@koendecock depends on how far I get with #380 this coming week... either way I think a minor release could happen some time next week

@vaadin-miki vaadin-miki modified the milestones: Backlog, Next release Sep 9, 2022
@vaadin-miki vaadin-miki changed the title Number fields should support setRequired() Add HasRequired to control setRequired in components Sep 9, 2022
vaadin-miki added a commit that referenced this issue Sep 9, 2022
@vaadin-miki vaadin-miki mentioned this issue Sep 9, 2022
vaadin-miki added a commit that referenced this issue Sep 9, 2022
vaadin-miki added a commit that referenced this issue Sep 9, 2022
#382 #380 #387 #390 #391 #386 #388 #395 #396 done

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: vaadin-miki <vaadin-miki@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@vaadin-miki
Copy link
Owner

fyi @koendecock - version 0.14.0 has been just released and should be available from the Directory (both v23 and v14 versions) - please report any issues

how it ended up is an interface HasRequired through which you can control setRequired() - I made those components that made sense implementations of it (number fields, date picker, text field and text area)

@koendecock
Copy link
Author

@vaadin-miki Great! Thanks for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api All things related with adding, removing and modifying public API. enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants