Skip to content

[custom-field] Allow passing any type as value #558

@manolo

Description

@manolo

Allowing to pass arbitrary types to children elements would enable support for element like vaadin-checkbox-group. Note that this feature will also fix vaadin/vaadin-custom-field#76

This works

@customElement('vaadin-custom-view2')
export class VaadinCustomView extends LitElement {

  @query('#field1') field1: any;

  async updated() {
    this.field1.value = ['1', '3'];
  }  

  render() {
    console.log("render")
    return html`
        <vaadin-checkbox-group id="field1">
          <vaadin-checkbox value="1">foo</vaadin-checkbox>
          <vaadin-checkbox value="2">bar</vaadin-checkbox>
          <vaadin-checkbox value="3">baz</vaadin-checkbox>
        </vaadin-checkbox-group>  
    `;
  }
}

But this does not work

@customElement('vaadin-custom-view2')
export class VaadinCustomView extends LitElement {

  @query('#field1') field1: any;

  async updated() {
    this.field1.value = ['1', '3'];
  }  

  render() {
    console.log("render")
    return html`
      <vaadin-custom-field id="field1">
        <vaadin-checkbox-group>
          <vaadin-checkbox value="1">foo</vaadin-checkbox>
          <vaadin-checkbox value="2">bar</vaadin-checkbox>
          <vaadin-checkbox value="3">baz</vaadin-checkbox>
        </vaadin-checkbox-group>  
      </vaadin-custom-field>
    `;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions