Skip to content

Move Picker's state icon in a method, so that it could be overridden from outside #3076

@razvancir96

Description

@razvancir96

Code of conduct

  • I agree to follow this project's code of conduct.

Description of issue

We need to add a loading spinner inside the picker's button, which is not supported right now. There is an invalid icon supported and we can extract that logic in a separate method, which can be overridden from outside. This way, the component's API and DOM structure isn't changed, but the consumers gain more flexibility.

What we have now (in render):

${this.invalid
        ? html`
              <sp-icon-alert
                  class="validation-icon"
              ></sp-icon-alert>
          `
        : nothing}

The more flexible version:

protected renderStateIcon(): TemplateResult | typeof nothing {
    if (!this.invalid) {
        return nothing;
    }
    return html`
        <sp-icon-alert class="validation-icon"></sp-icon-alert>
    `;
}

In render:
${this.renderStateIcon()}

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