File tree Expand file tree Collapse file tree 2 files changed +24
-14
lines changed
src/BootstrapBlazor/Components/Input Expand file tree Collapse file tree 2 files changed +24
-14
lines changed Original file line number Diff line number Diff line change 44<div @attributes =" AdditionalAttributes" id =" @Id" class =" @ClassString" >
55 @for ( var index = 0 ; index < Digits ; index ++ )
66 {
7- if (IsReadonly || IsDisabled )
8- {
9- < span class = " @ItemClassString" > @GetValueString (index )< / span >
10- }
11- else
12- {
13- var charIndex = index ;
14- <input type =" @TypeString" maxlength =" @MaxLengthString" inputmode =" @TypeModeString" placeholder =" @PlaceHolder"
15- class =" @ItemClassString" value =" @GetValueString(index)" @onchange =" e => OnChanged(e.Value!.ToString(), charIndex)" />
16- }
7+ <span class =" @ItemClassString" >
8+ @if (IsReadonly || IsDisabled )
9+ {
10+ @GetValueString(index)
11+ }
12+ else
13+ {
14+ var charIndex = index ;
15+ <input type =" @TypeString" class =" @InputClassString"
16+ maxlength =" @MaxLengthString" inputmode =" @TypeModeString" placeholder =" @PlaceHolder"
17+ value =" @GetValueString(index)" @onchange =" e => OnChanged(e.Value!.ToString(), charIndex)" />
18+ }
19+ </span >
1720 }
1821</div >
Original file line number Diff line number Diff line change @@ -40,11 +40,15 @@ public partial class OtpInput
4040 . Build ( ) ;
4141
4242 private string ? ItemClassString => CssBuilder . Default ( "bb-opt-item" )
43- . AddClass ( "input-number-fix" , Type == OtpInputType . Number )
4443 . AddClass ( "disabled" , IsDisabled )
4544 . AddClass ( ValidCss )
4645 . Build ( ) ;
4746
47+ private string ? InputClassString => CssBuilder . Default ( )
48+ . AddClass ( "input-number-fix" , Type == OtpInputType . Number )
49+ . AddClass ( "disabled" , IsDisabled )
50+ . Build ( ) ;
51+
4852 private string TypeString => Type switch
4953 {
5054 OtpInputType . Number => "number" ,
@@ -74,11 +78,14 @@ protected override void OnParametersSet()
7478 base . OnParametersSet ( ) ;
7579
7680 _values = new char [ Digits ] ;
77- for ( var index = 0 ; index < Digits ; index ++ )
81+ if ( Value != null )
7882 {
79- if ( index < Value . Length )
83+ for ( var index = 0 ; index < Digits ; index ++ )
8084 {
81- _values [ index ] = Value [ index ] ;
85+ if ( index < Value . Length )
86+ {
87+ _values [ index ] = Value [ index ] ;
88+ }
8289 }
8390 }
8491 }
You can’t perform that action at this time.
0 commit comments