11// Licensed to the .NET Foundation under one or more agreements. 
22// The .NET Foundation licenses this file to you under the MIT license. 
33
4+ using  Aspire . Dashboard . ConsoleLogs ; 
45using  Aspire . Dashboard . Resources ; 
56using  Microsoft . AspNetCore . Components ; 
67using  Microsoft . FluentUI . AspNetCore . Components ; 
@@ -66,9 +67,6 @@ public partial class GridValue
6667    [ Parameter ] 
6768    public  EventCallback < bool >  IsMaskedChanged  {  get ;  set ;  } 
6869
69-     [ Parameter ] 
70-     public  int ?  MaxDisplayLength  {  get ;  set ;  } 
71- 
7270    [ Parameter ] 
7371    public  string ?  ToolTip  {  get ;  set ;  } 
7472
@@ -80,8 +78,11 @@ public partial class GridValue
8078
8179    private  readonly  Icon  _maskIcon  =  new  Icons . Regular . Size16 . EyeOff ( ) ; 
8280    private  readonly  Icon  _unmaskIcon  =  new  Icons . Regular . Size16 . Eye ( ) ; 
81+     private  readonly  string  _cellTextId  =  $ "celltext-{ Guid . NewGuid ( ) : N} "; 
8382    private  readonly  string  _copyId  =  $ "copy-{ Guid . NewGuid ( ) : N} "; 
8483    private  readonly  string  _menuAnchorId  =  $ "menu-{ Guid . NewGuid ( ) : N} "; 
84+     private  string ?  _value ; 
85+     private  string ?  _formattedValue ; 
8586    private  bool  _isMenuOpen ; 
8687
8788    protected  override  void  OnInitialized ( ) 
@@ -90,23 +91,44 @@ protected override void OnInitialized()
9091        PostCopyToolTip  =  Loc [ nameof ( ControlsStrings . GridValueCopied ) ] ; 
9192    } 
9293
93-     private  string  GetContainerClass ( )  =>  EnableMasking  ?  "container masking-enabled"  :  "container" ; 
94- 
95-     private  async  Task  ToggleMaskStateAsync ( ) 
94+     protected  override  void  OnParametersSet ( ) 
9695    { 
97-         IsMasked  =  ! IsMasked ; 
98- 
99-         await  IsMaskedChanged . InvokeAsync ( IsMasked ) ; 
96+         if  ( _value  !=  Value ) 
97+         { 
98+             _value  =  Value ; 
99+ 
100+             if  ( UrlParser . TryParse ( _value ,  out  var  url ) ) 
101+             { 
102+                 _formattedValue  =  url ; 
103+             } 
104+             else 
105+             { 
106+                 _formattedValue  =  _value ; 
107+             } 
108+         } 
100109    } 
101110
102-     private   string   TrimLength ( string ?   text ) 
111+     protected   override   async   Task   OnAfterRenderAsync ( bool   firstRender ) 
103112    { 
104-         if  ( text   is  not  null   &&   MaxDisplayLength   is   int   maxLength   &&   text . Length   >   maxLength ) 
113+         if  ( firstRender ) 
105114        { 
106-             return  text [ ..maxLength ] ; 
115+             // If the value and formatted value are different then there are hrefs in the text. 
116+             // Add a click event to the cell text that stops propagation if a href is clicked. 
117+             // This prevents details view from opening when the value is in a main page grid. 
118+             if  ( _value  !=  _formattedValue ) 
119+             { 
120+                 await  JS . InvokeVoidAsync ( "setCellTextClickHandler" ,  _cellTextId ) ; 
121+             } 
107122        } 
123+     } 
108124
109-         return  text  ??  "" ; 
125+     private  string  GetContainerClass ( )  =>  EnableMasking  ?  "container masking-enabled"  :  "container" ; 
126+ 
127+     private  async  Task  ToggleMaskStateAsync ( ) 
128+     { 
129+         IsMasked  =  ! IsMasked ; 
130+ 
131+         await  IsMaskedChanged . InvokeAsync ( IsMasked ) ; 
110132    } 
111133
112134    private  void  ToggleMenuOpen ( ) 
0 commit comments