-
Notifications
You must be signed in to change notification settings - Fork 763
[clrDgSelectable]="false" in clr-grid does not disable select in v-4 #4993
Comments
There is a work-around for this; If you change the order of the arguments everything will work: // Before
<clr-dg-row [clrDgSelectable]="state" *clrDgItems="let tenant of tenants" [clrDgItem]="tenant">
// After
<clr-dg-row [clrDgItem]="tenant" [clrDgSelectable]="state" *clrDgItems="let tenant of tenants"> The issue is that we are doing some calculations inside the |
@Shijir can you share a bit about the order problem, I remember you had discovered changes in a previous Angular build but the details elude me. |
I could share some of my findings. The issue is how and when Angular decide to assign values from There are good examples here So the best and correct way of doing it - is to not depend on other inputs values inside The bigger problem is that is hard to say where else this had been done - we have a lot of The best thing that we could do is to keep an eye for this type of pattern. @Input('name') name: string;
@Input('title')
public set title(n: string) {
this.fullname = `${n} ${this.name}`; /* this.name may be undefined at that point */
} Better will be to use the lifecycle to assign it. onChanges(changes: SimpleChanges) {
if (
/* handle only the inputs that we care about */
changes.title
/* make sure that we won't run the code too many times */
&& changes.title.previousValue !== changes.title.currentValue
) {
/* handle changes goes here */
}
} There is not only the use case when there is the use of another input inside an input (inception). Some @Input('name') string;
@Input('age')
public set age(number: number) {
this.calculateSomething(number)
}
private calculateSomething(age) {
if (this.name === 'papa') { /* this.name could be `undefined` */
return true;
}
return age > 21;
} This is the third time that we have an issue related to this. This is the issue that @gnomeontherun mention above |
@Shijir can you please share about the order problem too from your experience? |
So before Ivy, no matter in what order users provide their input values, their values used to be assigned in the order their corresponding So in the example of private _item: T;
@Input('clrDgItem') set item(value: T) {
this._item = value;
if(this._selectable) {
this.clrDgSelectable = this._selectable;
}
}
private _selectable: boolean;
@Input('clrDgSelectable')
public set clrDgSelectable(value: boolean) {
if(this._item) {
this.selection.lockItem(this._item, value === false);
} else {
// attempted value during the absence of this._item
this._selectable = value;
}
} |
Can you explain in some more detail why do you prefer it to ngOnChange, please? |
Issue vmware-archive#4993 Signed-off-by: Bozhidar Dryanovski <bozhidar.dryanovski@gmail.com>
Issue #4993 Signed-off-by: Bozhidar Dryanovski <bozhidar.dryanovski@gmail.com>
Issue vmware-archive#4993 Signed-off-by: Bozhidar Dryanovski <bozhidar.dryanovski@gmail.com>
Issue #4993 Signed-off-by: Bozhidar Dryanovski <bozhidar.dryanovski@gmail.com>
@bdryanovski can you confirm that your changes addressed this bug and close it? |
This is still an issue with v4.0.14 Workaround of putting [clrDgSelectable] as the last parameter does work. |
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. |
Describe the bug
using [clrDgSelectable]="false" in clr-grid does not disable select in v-4
How to reproduce
https://stackblitz.com/edit/clarity-v4-light-theme-k7dk5i?file=src%2Fapp%2Fapp.component.html
Versions
App
Device:
Additional notes
Add any other notes about the problem here.
The text was updated successfully, but these errors were encountered: