Flow: Rename the current Label component to NativeLabel and create a new Label that is compatible with FW8 Label

Created on 11 Jul 2018  路  9Comments  路  Source: vaadin/flow

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:

  1. Rename the current class from Label to NativeLabel (using the same naming structure as the NativeButton);
  2. Create a new Label class that behaves exactly like the old Label from FW8;
  3. Update demos and starters to use the new Label class;
  4. Update the documentation explaining the difference between those two classes.
breaking change enhancement

Most helpful comment

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.

All 9 comments

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_.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SomeoneToIgnore picture SomeoneToIgnore  路  4Comments

Artur- picture Artur-  路  4Comments

joheriks picture joheriks  路  4Comments

pleku picture pleku  路  4Comments

anezthes picture anezthes  路  4Comments