Mark changed fields

I believe it’s best practice to somehow mark a field when it’s value has been changed, e. g. with a * added to the label, or some color.

In our old Vaadin 8 application we used setIcon() with a wrench icon, but this doesn’t exist anymore in Flow. So I wonder what you’d recommend nowadays?

1 Like

We set a CSS class that will mark the changed field

If your users are accustomed to seeing icons, I would recommend keeping using icons. Input fields support components in various places (prefix slot, suffix slot, helper text…) so it’s just a matter of figuring out what suits you best.

Thanks for your replies.
I’m actually surprised that there is no default functionality - maybe worth a feature request?

prefix and suffix components are not available e. g. in CheckBox and RadioButtonGroup, so this doesn’t really work in a consistent way

There is a related feature request that you can upvote: Option to render tooltip icon in the label of a field · Issue #5786 · vaadin/web-components · GitHub

To get the closest to the existing application, we’d like to put the icon in front of the label. Could the helper text be tweaked with CSS so it’s rendered before the label? Would be great to get some hints how to to that, as I am not a CSS pro.

I do not have demo for the latest Vaadin version, but I have Vaadin 8 demo about this. The lucky thing is that most important parts the code should still be very similar as it is mostly about Binder and setting some CSS class names to target fields.

So the things you need to know is that Binder does have getter for changed bindings. Also from Vaadin 24.5 onwards and also in Vaadin 8.27.0 there is improved change tracking, which is also demonstrated in this code.

I my demo I am showing the previous value in tooltip, but Flow offers more options, like you could show it in helper text.

Lumo theme also has builtin warning color styles, which you can use with LumoUtility, without need to define additional CSS. That could fit well with changed fields.

Thanks, but in Vaadin 8 (where I’m coming from) I just called setIcon() and was done. This doesn’t exist anymore in Flow 24, so I’m not sure what to make with your example.

Check the newest Binder API’s and how they could help you streamline rest of your code. Yes, not related the icon question itself.