File tree Expand file tree Collapse file tree 3 files changed +38
-10
lines changed
src/BootstrapBlazor/Components/Upload Expand file tree Collapse file tree 3 files changed +38
-10
lines changed Original file line number Diff line number Diff line change @@ -209,5 +209,5 @@ protected override void OnParametersSet()
209209 BrowserButtonIcon ??= IconTheme . GetIconByKey ( ComponentIcons . ButtonUploadBrowserButtonIcon ) ;
210210 }
211211
212- private bool CheckStatus ( ) => IsDisabled || CanUpload ( ) == false ;
212+ private bool CheckStatus ( ) => IsDisabled || ! CanUpload ( ) ;
213213}
Original file line number Diff line number Diff line change @@ -102,15 +102,7 @@ protected override void OnParametersSet()
102102 DeleteButtonIcon ??= IconTheme . GetIconByKey ( ComponentIcons . InputUploadDeleteButtonIcon ) ;
103103 }
104104
105- private bool CheckStatus ( )
106- {
107- if ( IsDisabled )
108- {
109- return true ;
110- }
111-
112- return ! CanUpload ( ) ;
113- }
105+ private bool CheckStatus ( ) => IsDisabled || ! CanUpload ( ) ;
114106
115107 private async Task TriggerDeleteFile ( )
116108 {
Original file line number Diff line number Diff line change 33// See the LICENSE file in the project root for more information.
44// Maintainer: Argo Zhang([email protected] ) Website: https://www.blazor.zone 55
6+ using AngleSharp . Dom ;
67using Microsoft . AspNetCore . Components . Forms ;
78using System . ComponentModel . DataAnnotations ;
89
@@ -84,6 +85,41 @@ public void ButtonUpload_IsDisabled_Ok()
8485 Assert . DoesNotContain ( "disabled=\" disabled\" " , button . ToMarkup ( ) ) ;
8586 }
8687
88+ [ Fact ]
89+ public void InputUpload_IsMultiple ( )
90+ {
91+ var cut = Context . RenderComponent < ButtonUpload < string > > ( pb =>
92+ {
93+ pb . Add ( a => a . IsMultiple , false ) ;
94+ } ) ;
95+
96+ // 禁用多选功能
97+ cut . DoesNotContain ( "multiple=\" multiple\" " ) ;
98+
99+ // 给定已上传文件后上传按钮应该被禁用
100+ cut . SetParametersAndRender ( pb =>
101+ {
102+ pb . Add ( a => a . DefaultFileList ,
103+ [
104+ new UploadFile ( ) { FileName = "test1.png" } ,
105+ new UploadFile ( ) { FileName = "test2.png" }
106+ ] ) ;
107+ } ) ;
108+ var button = cut . Find ( ".btn-browser" ) ;
109+ Assert . True ( button . IsDisabled ( ) ) ;
110+
111+ // 开启多选功能
112+ cut . SetParametersAndRender ( pb =>
113+ {
114+ pb . Add ( a => a . IsMultiple , true ) ;
115+ } ) ;
116+ cut . Contains ( "multiple=\" multiple\" " ) ;
117+
118+ // 给定已上传文件后上传按钮不应该被禁用
119+ button = cut . Find ( ".btn-browser" ) ;
120+ Assert . False ( button . IsDisabled ( ) ) ;
121+ }
122+
87123 [ Fact ]
88124 public void ButtonUpload_ValidateForm_Ok ( )
89125 {
You can’t perform that action at this time.
0 commit comments