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 Microsoft . AspNetCore . Components . Web ;
7+
68namespace BootstrapBlazor . Components ;
79
810/// <summary>
9- /// Textarea 组件
11+ /// Textarea component
1012/// </summary>
1113public partial class Textarea
1214{
1315 /// <summary>
14- /// 滚动到顶部
16+ /// Scroll to the top
1517 /// </summary>
1618 /// <returns></returns>
1719 public Task ScrollToTop ( ) => InvokeVoidAsync ( "execute" , Id , "toTop" ) ;
1820
1921 /// <summary>
20- /// 滚动到数值
22+ /// Scroll to a specific value
2123 /// </summary>
2224 /// <returns></returns>
2325 public Task ScrollTo ( int value ) => InvokeVoidAsync ( "execute" , Id , "to" , value ) ;
2426
2527 /// <summary>
26- /// 滚动到底部
28+ /// Scroll to the bottom
2729 /// </summary>
2830 /// <returns></returns>
2931 public Task ScrollToBottom ( ) => InvokeVoidAsync ( "execute" , Id , "toBottom" ) ;
3032
3133 /// <summary>
32- /// 获得/设置 是否自动滚屏 默认 false
34+ /// Gets or sets whether auto-scroll is enabled. Default is false.
3335 /// </summary>
3436 [ Parameter ]
3537 public bool IsAutoScroll { get ; set ; }
3638
3739 /// <summary>
38- /// 获得/设置 是否使用 Shift + Enter 代替原回车按键行为 默认为 false
40+ /// Gets or sets whether Shift + Enter replaces the default Enter key behavior. Default is false.
3941 /// </summary>
4042 [ Parameter ]
4143 public bool UseShiftEnter { get ; set ; }
4244
4345 /// <summary>
44- /// 获得 客户端是否自动滚屏标识
46+ /// Gets the client-side auto-scroll identifier.
4547 /// </summary>
4648 private string ? AutoScrollString => IsAutoScroll ? "auto" : null ;
4749
@@ -61,4 +63,20 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
6163 await InvokeVoidAsync ( "execute" , Id , "update" ) ;
6264 }
6365 }
66+
67+ /// <summary>
68+ /// Client-side EnterCallback method
69+ /// </summary>
70+ /// <returns></returns>
71+ [ JSInvokable ]
72+ public override async Task EnterCallback ( KeyboardEventArgs e , string val )
73+ {
74+ if ( OnEnterAsync != null && TriggerEnter ( e ) )
75+ {
76+ CurrentValueAsString = val ;
77+ await OnEnterAsync ( Value ) ;
78+ }
79+ }
80+
81+ private bool TriggerEnter ( KeyboardEventArgs e ) => UseShiftEnter ? e . ShiftKey : true ;
6482}
0 commit comments