File tree 5 files changed +71
-12
lines changed 5 files changed +71
-12
lines changed Original file line number Diff line number Diff line change @@ -13,4 +13,9 @@ public class FluentKeyPressEventArgs : EventArgs
13
13
/// Gets the key press event data associated with the current operation.
14
14
/// </summary>
15
15
public required KeyPress KeyPress { get ; init ; }
16
+
17
+ /// <summary>
18
+ /// Gets the value associated with this instance.
19
+ /// </summary>
20
+ public required string Value { get ; init ; }
16
21
}
Original file line number Diff line number Diff line change @@ -109,11 +109,18 @@ public FluentTextArea()
109
109
[ JSInvokable ]
110
110
public async Task ChangeAfterKeyPressHandlerAsync ( string value , KeyPress key )
111
111
{
112
- await ChangeHandlerAsync ( new ChangeEventArgs ( ) { Value = value } ) ;
112
+ await ChangeHandlerAsync ( new ChangeEventArgs ( )
113
+ {
114
+ Value = value ,
115
+ } ) ;
113
116
114
117
if ( OnChangeAfterKeyPress . HasDelegate )
115
118
{
116
- await OnChangeAfterKeyPress . InvokeAsync ( new FluentKeyPressEventArgs ( ) { KeyPress = key } ) ;
119
+ await OnChangeAfterKeyPress . InvokeAsync ( new FluentKeyPressEventArgs ( )
120
+ {
121
+ Value = value ,
122
+ KeyPress = key ,
123
+ } ) ;
117
124
}
118
125
}
119
126
Original file line number Diff line number Diff line change @@ -135,11 +135,18 @@ public FluentTextInput()
135
135
[ JSInvokable ]
136
136
public async Task ChangeAfterKeyPressHandlerAsync ( string value , KeyPress key )
137
137
{
138
- await ChangeHandlerAsync ( new ChangeEventArgs ( ) { Value = value } ) ;
138
+ await ChangeHandlerAsync ( new ChangeEventArgs ( )
139
+ {
140
+ Value = value ,
141
+ } ) ;
139
142
140
143
if ( OnChangeAfterKeyPress . HasDelegate )
141
144
{
142
- await OnChangeAfterKeyPress . InvokeAsync ( new FluentKeyPressEventArgs ( ) { KeyPress = key } ) ;
145
+ await OnChangeAfterKeyPress . InvokeAsync ( new FluentKeyPressEventArgs ( )
146
+ {
147
+ Value = value ,
148
+ KeyPress = key ,
149
+ } ) ;
143
150
}
144
151
}
145
152
Original file line number Diff line number Diff line change 18
18
{
19
19
// Arrange && Act
20
20
var cut = Render (@< FluentTextArea Appearance = " @TextAreaAppearance.Outline"
21
- Autofocus = " true"
22
- AriaLabel = " My aria label"
23
- Label = " My Label"
24
- Name = " MyName"
25
- Placeholder = " My help"
26
- Value = " My Value" / >
21
+ Autofocus = " true"
22
+ AriaLabel = " My aria label"
23
+ Label = " My Label"
24
+ Name = " MyName"
25
+ Placeholder = " My help"
26
+ Value = " My Value" / >
27
27
);
28
28
29
29
// Assert
96
96
// Arrange && Act
97
97
var cut = Render (
98
98
@< FluentTextArea >
99
- < LabelTemplate >< div style = " font-weight: bold;" > My label < / div >< / LabelTemplate >
100
- < / FluentTextArea >
99
+ < LabelTemplate >< div style = " font-weight: bold;" > My label < / div >< / LabelTemplate >
100
+ < / FluentTextArea >
101
101
);
102
102
103
103
// Assert
169
169
170
170
Assert .Equal (expected , value );
171
171
}
172
+
173
+ [Fact ]
174
+ public async Task FluentTextArea_ChangeAfterKeyPress ()
175
+ {
176
+ var value = string .Empty ;
177
+ var lastEventArgs = new FluentKeyPressEventArgs () { KeyPress = new KeyPress (), Value = " " };
178
+
179
+ // Arrange && Act
180
+ var cut = Render (@< FluentTextArea @bind - Value = " @value"
181
+ ChangeAfterKeyPress = " @([KeyPress.For(KeyCode.Enter)])"
182
+ OnChangeAfterKeyPress = " @(e => lastEventArgs = e)" / >
183
+ );
184
+
185
+ // Act
186
+ await cut .FindComponent <FluentTextArea >().Instance .ChangeAfterKeyPressHandlerAsync (" MyValue" , KeyPress .For (KeyCode .Enter ));
187
+
188
+ // Assert
189
+ Assert .Equal (KeyCode .Enter , lastEventArgs .KeyPress .Key );
190
+ Assert .Equal (" MyValue" , lastEventArgs .Value );
191
+ }
172
192
}
Original file line number Diff line number Diff line change 181
181
182
182
Assert .Equal (expected , value );
183
183
}
184
+
185
+ [Fact ]
186
+ public async Task FluentInputText_ChangeAfterKeyPress ()
187
+ {
188
+ var value = string .Empty ;
189
+ var lastEventArgs = new FluentKeyPressEventArgs () { KeyPress = new KeyPress (), Value = " " };
190
+
191
+ // Arrange && Act
192
+ var cut = Render (@< FluentTextInput @bind - Value = " @value"
193
+ ChangeAfterKeyPress = " @([KeyPress.For(KeyCode.Enter)])"
194
+ OnChangeAfterKeyPress = " @(e => lastEventArgs = e)" / >
195
+ );
196
+
197
+ // Act
198
+ await cut .FindComponent <FluentTextInput >().Instance .ChangeAfterKeyPressHandlerAsync (" MyValue" , KeyPress .For (KeyCode .Enter ));
199
+
200
+ // Assert
201
+ Assert .Equal (KeyCode .Enter , lastEventArgs .KeyPress .Key );
202
+ Assert .Equal (" MyValue" , lastEventArgs .Value );
203
+ }
184
204
}
You can’t perform that action at this time.
0 commit comments