microsoft / vsts-extension-multivalue-control

A work item form control which allows selection of multiple values.
MIT License
46 stars 44 forks source link

Bug: "maximum display length" setting is not taking effect #280

Closed liyongscb closed 7 months ago

liyongscb commented 7 months ago

We have lengthy option, by default it will be displayed with first 35 char. We configured "maximum display length" but it is not working as expected.

Note: it used to work, but recently notice it is not working anymore.

### Tasks
mavsguy482 commented 7 months ago

We are also experiencing this issue. It used to work, and now it does not. The custom value we have entered on the control extension is 75. I attempted to correct this issue by clearing out the value and saving (thus reverting to the default 35 character limit), and then going back into the control extension and setting the value back to 75 and then saving. This made no difference.

The display is showing 30 characters, plus the periods (i.e. ...), so not even the 35 which is supposed to be the default value.

I have confirmed this issue is affecting our multivalue controls in two separate Azure DevOps processes (both within the same organization).

liyongscb commented 7 months ago

@AminTi my colleague @AlbertArulPrakash found below:

The error seems to be in the file \src\MultiValueControl.tsx Line 109: label={this._wrapText(o.length > 30 ? ${o.slice(0, 30)}... : o)}

this line should use the property named _labelDisplayLength which can be configured (default value 35).

mavsguy482 commented 7 months ago

I think Line 109 should probably just be: label={this._wrapText(o)} because the _wrapText function handles adding the ellipsis if the length of the label text is greater than the _labelDisplayLength property.

private _wrapText(text: string){
    return text.length > this._labelDisplayLength ? `${text.slice(0,this._labelDisplayLength)}...` : text;
} 
AlbertArulPrakash commented 7 months ago

I think Line 109 should probably just be: label={this._wrapText(o)} because the _wrapText function handles adding the ellipsis if the length of the label text is greater than the _labelDisplayLength property.

private _wrapText(text: string){
    return text.length > this._labelDisplayLength ? `${text.slice(0,this._labelDisplayLength)}...` : text;
} 

using _labelDisplayLength can be configured (using config files located in config folder. By default it is 35 characters. Line 34 in same file has the initiator of _labelDisplayLength: private readonly _labelDisplayLength: number = VSS.getConfiguration().witInputs.LabelDisplayLength ? VSS.getConfiguration().witInputs.LabelDisplayLength : 35;

The azure-devops-extension.json contains the info about this.

AminTi commented 7 months ago

Hello everyone, we appreciate your contributions to the community. The issues have been resolved.