Currently the Label component creates a <label> element in the client, which makes it not suitable to rendering loose text in the page, since the <label> in meant to be used in conjunction with other elements (usually <input>). This makes it semantically different from the old Label in FW8, which creates a <div> instead.
On top of that, the <label> element is an interactive content element, which makes it behave differently than a regular text in the page. For example, when used inside a Grid cell, clicking on a label doesn't trigger the selection of the row (see https://github.com/vaadin/flow/issues/4313 for details).
My proposal to this issue is the following:
Label to NativeLabel (using the same naming structure as the NativeButton);Label class that behaves exactly like the old Label from FW8;I wouldn't rename Label. New developers approaching Vaadin will likely expect Label to be <label>, as Div is <div> and H1 is <h1>, and FW8 users are being made well aware that many things changed in Flow to be more HTML-intuitive.
I'd see more fit just a note in the Label JavaDoc warning about this.
I think it's too late to rename.
May be we can do another class and add a reference to it everywhere in javadocs with huge warning.
Agree with the comments above. Rename would be just unnecessary breaking change. But we should add some javadoc explaining the difference for the ones coming from FW8 as @heruan suggested. Maybe with a see also -link to Text / Span components.
I think it's too late to rename.
This proposal is not for Vaadin 10.
I think it doesn't matter since the next release should be 100% compatible with V10.
And it doesn't need to be for the next version.
The point is to avoid cases like https://github.com/vaadin/flow/issues/4313 to happen in the future.
Should we then also rename Div to NativeDiv to stay consistent?
Should also be mentioned that the JavaDocs have been clarified in https://github.com/vaadin/flow/pull/4383.
I see no reason to do any drastic changes anymore for this - yes it is something that existing (or swing based) users run into, but there has not really been that much questions and uproar on this topic that would make us want to change things anymore.
So I'm quite close to closing this as _won't fix_.
Most helpful comment
I wouldn't rename
Label. New developers approaching Vaadin will likely expectLabelto be<label>, asDivis<div>andH1is<h1>, and FW8 users are being made well aware that many things changed in Flow to be more HTML-intuitive.I'd see more fit just a note in the
LabelJavaDoc warning about this.