havit / Havit.Blazor

Free Bootstrap 5 components for ASP.NET Blazor + optional enterprise-level stack for Blazor development (gRPC code-first, layered architecture, localization, auth, ...)
https://havit.blazor.eu
MIT License
475 stars 66 forks source link

[HxInputDate] FocusAsync() not working + other indirect input-components might be also affected #791

Closed hakenr closed 4 months ago

hakenr commented 4 months ago

Discussed in https://github.com/havit/Havit.Blazor/discussions/785

Originally posted by **chobo2** April 4, 2024 Hi I am trying to use "FocusAsync" but it never focuses on it. I tried taking the default code and added a reference ``` @code { public DateTime value { get; set; } private HxInputDate testInputDate; protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { testInputDate().FocusAsync() } } } ``` In my actual application I get an error telling me that it can't be done after first render or soemthing like that though it could be because the HxInputDate is in a child component but since I can't even get it working with the example code I thought I would start there. Also on a side note, is there away to get the calendar to put when you tab into a HxInputDate?
hakenr commented 4 months ago

Some input-components use indirect setup where the input-element to be focused is contained in internal component being wrapped by the HxInputBase<>-derived component itself.

The HxInputBase<>.FocusAsync() call has to be passed to the underlying internal component and the contained input-element.

chobo2 commented 2 months ago

Some input-components use indirect setup where the input-element to be focused is contained in internal component being wrapped by the HxInputBase<>-derived component itself.

The HxInputBase<>.FocusAsync() call has to be passed to the underlying internal component and the contained input-element.

  • [x] HxInputDate
  • [x] HxInputDateRange
  • [x] HxAutosuggest
  • [x] HxMultiSelect
  • [x] HxInputTags
  • [x] HxSearchBox

Thanks for checking into this, I just saw this message now.

I did try in the latest version and confirm the cursor does now start in that box.

Is it possible to set it to popup the calendar as well? I can't get the calendar to popup when I tab into those boxes or if I do this FocusAsync() which leads to having to do a secondary click.

hakenr commented 2 months ago

@chobo2 Thanks for the feedback. I added the logic to show the corresponding dropdown when the input is focused with FocusAsync().