Clarity: Directive clrLabelSize doesn't work

Created on 1 Apr 2020  路  8Comments  路  Source: vmware/clarity

Describe the bug

I've tried to use clrLabelSize="6" but it doesn't change a label class from clr-col-md-2 to clr-col-md-6

How to reproduce

https://stackblitz.com/edit/angular-zxgdaa?file=src/app/app.component.html

A label tag has class clr-col-md-2.

Expected behavior

A label tag should have class clr-col-md-4.

Versions

App

  • Angular: 8.2.14
  • Clarity: 3.0.1

Device:

  • Type: PC
  • OS: Ubuntu 19.10
  • Browser Google Chrome
  • Version 80.0.3987.162
@clangular forms has workaround backlog bug

Most helpful comment

I've had the same problem. Using input brackets for angular property solved the problem

Instead of this:
<form clrForm clrLayout="horizontal" clrLabelSize="6">

try this:
<form clrForm clrLayout="horizontal" [clrLabelSize]="6">

All 8 comments

clr-input-container provides both ControlClassService && ControlIdService.

The issue seems to be in the ClrLabel directive ngOnInit routine around here: https://github.com/vmware/clarity/blob/master/src/clr-angular/forms/common/label.ts#L34

Labeled and added to backlog.

I've had the same problem. Using input brackets for angular property solved the problem

Instead of this:
<form clrForm clrLayout="horizontal" clrLabelSize="6">

try this:
<form clrForm clrLayout="horizontal" [clrLabelSize]="6">

I've found this workaround but a framework shouldn't swallow an error. Indeed it must either log it in the dev console or throw an exception.

And before creating an issue I've checked a documentation and it states that:

For example if you pass clrLabelSize="4" it will size the controls to use 8 grid columns for a total of 12 columns.

Thanks for the debugging @realmfoo! Yes it should handle numbers without [] and the workaround is to use a binding for now. We'll have to investigate the reason this is broken for a fix.

@gnomeontherun, do you think we should accept numbers without [] or instead throw an exception / show a warning?

Generally, it seems helpful to accept it instead of throwing exceptions. We should just coerce the value as it comes in, as that is best for us anyways to ensure typing.

Hi there 馃憢, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed issues after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amellnik picture amellnik  路  3Comments

JohannesRudolph picture JohannesRudolph  路  4Comments

Vad1mo picture Vad1mo  路  3Comments

thojo picture thojo  路  3Comments

BugsyFTW picture BugsyFTW  路  3Comments