Onfocus / onblur not working with RadzenDatePicker

I have never posted here before, hopefully the code will come through.

In my application, I have created a control for receiving Scanner input, it pulls focus every 3 seconds. Outside of the control, when a user enters another field where the cursor must allow keyboard entry, that field calls (using @onfocus) a method to disable the timer so it won't pull focus to the scanner. Leaving the field, It then calls RestoreScanner (using @onblur). This works great in the RadzenTextBox but not at all for RadzenDatePicker.

<RadzenTextBox Placeholder="Enter NDC Number"
			   @onfocus="@SuppressScanning" @onblur="@RestoreScanning" />
<RadzenDatePicker @bind-Value=@ExpireDateInput
				  Placeholder="Enter Expiration Date"
				  @onfocus="@SuppressScanning" @onblur="@RestoreScanning"
				  Class="w-100 mb-6" />

It also doesn't work while in a drop down list if moving up or down the list with keys.

Hi @Harvey_Myers,

You actually have posted a few times before - welcome back :slight_smile: Still your code didn't make it through - check our FAQ about how to format it so it displays properly.

RadzenDatePicker is a lot more complex than a regular textbox and this is why onfocus and onblur will not work - it renders more than one HTML element and the built-in DOM focus is not maintained. You can probably use the Change event instead.

I have been sitting here trying to remember how to post code. I've probably edited 5 times. lol. I'll read the FAQs now.

Thanks for remembering me, makes a nice birthday present. I've brought a nice growing company to adapt Radzen for their line of business apps. My 3rd app with Radzen.

Thanks @korchev glad to speak with you again.

Looking at the Api, I could call to suppress on the first character of the change but then for detection of the completion of the date, where I need to turn the time back on, perhaps ValueChanged or CurrentDateChanged to tell me that they have finished setting a date? They may use a combination of keyboard and mouse for this activity.

I assume the same complications are in place in the DropDown?

Yes. Perhaps only RadzenTextBox will fire focus and blur as you would expect it - it is just a simple <input> under the hood.

1 Like