File tree Expand file tree Collapse file tree
Source/Blazorise/Components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -680,6 +680,11 @@ private async ValueTask OpenCalendarAsync( bool focusCalendar )
680680 {
681681 NotifyCalendarStateChanged ( ) ;
682682 await InvokeAsync ( StateHasChanged ) ;
683+
684+ if ( focusCalendar )
685+ {
686+ await JSUtilitiesModule . Focus ( default , CalendarGridId , scrollToElement : false ) ;
687+ }
683688 }
684689
685690 await SynchronizeOutsidePointerSubscriptionAsync ( ) ;
@@ -1715,6 +1720,8 @@ protected override bool IsSameAsInternalValue( TValue value )
17151720
17161721 internal string CalendarId => $ "{ ElementId } -calendar";
17171722
1723+ internal string CalendarGridId => $ "{ CalendarId } -grid";
1724+
17181725 internal string PickerContainerId => $ "{ ElementId } -container";
17191726
17201727 internal DatePickerCalendarContext < TValue > CalendarContext
Original file line number Diff line number Diff line change 127127
128128 @if ( Parent .InputMode == DateInputMode .Month && Parent .CalendarView == DatePickerCalendarView .Month )
129129 {
130- <div @ref =" @CalendarGridElementRef "
130+ <div id =" @Parent.CalendarGridId "
131131 class =" @Calendar.MonthsClassNames"
132132 role =" grid"
133133 aria-label =" @Calendar.Label"
156156 }
157157 else if ( Parent .InputMode == DateInputMode .Month )
158158 {
159- <div @ref =" @CalendarGridElementRef "
159+ <div id =" @Parent.CalendarGridId "
160160 class =" @Calendar.MonthsClassNames"
161161 role =" grid"
162162 aria-label =" @Calendar.Label"
186186 }
187187 else
188188 {
189- <div @ref =" @CalendarGridElementRef "
189+ <div id =" @Parent.CalendarGridId "
190190 class =" @Calendar.GridClassNames"
191191 role =" grid"
192192 aria-label =" @Calendar.Label"
324324}
325325
326326@code {
327- private bool focusApplied ;
328-
329- private ElementReference CalendarGridElementRef ;
330-
331327 [CascadingParameter ]
332328 public DatePicker <TValue > Parent { get ; set ; }
333329
342338 private void OnCalendarStateChanged ()
343339 => _ = InvokeAsync ( StateHasChanged );
344340
345- protected override async Task OnAfterRenderAsync ( bool firstRender )
346- {
347- if ( Parent .CalendarVisible && ! Parent .Inline )
348- {
349- if ( Parent .FocusCalendarOnOpen && ! focusApplied )
350- {
351- focusApplied = true ;
352- await CalendarGridElementRef .FocusAsync ( preventScroll : true );
353- }
354- else if ( ! Parent .FocusCalendarOnOpen )
355- {
356- focusApplied = false ;
357- }
358- }
359- else
360- {
361- focusApplied = false ;
362- }
363- }
364-
365341 public void Dispose ()
366342 => Parent .CalendarStateChanged -= OnCalendarStateChanged ;
367343}
Original file line number Diff line number Diff line change @@ -487,6 +487,12 @@ private async ValueTask OpenMenuAsync( bool focusMenu )
487487
488488 NotifyMenuStateChanged ( ) ;
489489 await InvokeAsync ( StateHasChanged ) ;
490+
491+ if ( focusMenu )
492+ {
493+ await JSUtilitiesModule . Focus ( default , MenuControlsId , scrollToElement : false ) ;
494+ }
495+
490496 await SynchronizeOutsidePointerSubscriptionAsync ( ) ;
491497 }
492498
@@ -1004,6 +1010,8 @@ protected string PickerContainerClassNames
10041010 /// </summary>
10051011 protected internal string MenuId => $ "{ ElementId } -menu";
10061012
1013+ internal string MenuControlsId => $ "{ MenuId } -controls";
1014+
10071015 internal string PickerContainerId => $ "{ ElementId } -container";
10081016
10091017 internal TimePickerMenuContext < TValue > MenuContext
Original file line number Diff line number Diff line change 1717 role =" dialog"
1818 aria-modal =" false"
1919 aria-label =" @Menu.TimeText" >
20- <div @ref =" @MenuControlsElementRef "
20+ <div id =" @Parent.MenuControlsId "
2121 class =" @Menu.ControlsClassNames"
2222 role =" group"
2323 aria-label =" @Menu.TimeText"
105105}
106106
107107@code {
108- private bool focusApplied ;
109-
110- private ElementReference MenuControlsElementRef ;
111-
112108 [CascadingParameter ]
113109 public TimePicker <TValue > Parent { get ; set ; }
114110
123119 private void OnMenuStateChanged ()
124120 => _ = InvokeAsync ( StateHasChanged );
125121
126- protected override async Task OnAfterRenderAsync ( bool firstRender )
127- {
128- if ( Parent .MenuVisible && ! Parent .Inline )
129- {
130- if ( Parent .FocusMenuOnOpen && ! focusApplied )
131- {
132- focusApplied = true ;
133- await MenuControlsElementRef .FocusAsync ( preventScroll : true );
134- }
135- else if ( ! Parent .FocusMenuOnOpen )
136- {
137- focusApplied = false ;
138- }
139- }
140- else
141- {
142- focusApplied = false ;
143- }
144- }
145-
146122 public void Dispose ()
147123 => Parent .MenuStateChanged -= OnMenuStateChanged ;
148124}
You can’t perform that action at this time.
0 commit comments