radzenhq / radzen-blazor

Radzen Blazor is a set of 90+ free native Blazor UI components packed with DataGrid, Scheduler, Charts and robust theming including Material design and FluentUI.
https://www.radzen.com
MIT License
3.52k stars 786 forks source link

ReadOnly Datepicker with PopupRenderMode Initial allows user to open popup and select date. #1727

Closed johanpolak closed 6 days ago

johanpolak commented 6 days ago

Describe the bug If a datepicker is set to readonly, but de PopupRenderMode isn't set to OnDemand, the user is still able to open the popup and select a date. I guess this shouldn't be possible.

Expected behavior A user should not be able to open the popup and select a date if the datepicker is set to readonly, no matter what the PopupRenderMode is.

enchev commented 6 days ago

I'm unable to replicate such issue in our demos. The default value of PopupRenderMode is Initial: image

and using our first DatePicker demo with ReadOnly=true doesn't allow date selection: image

johanpolak commented 6 days ago

I see. Like this it doesn't allow date selection indeed. I changed the value of ReadOly from false to true by code after rendering. Then it is possible to open the popup and select a date. I will look into it how to make this work. Thanks for your quick response.

enchev commented 6 days ago

Changing the value of this property after render will not take desired effect - the component should be rerendered.

johanpolak commented 5 days ago

Hi @enchev,

I tried this. After changing the value for readonly I called the 'StateHasChanged' to force the component to be rerendered. However, a click on the datepicker still opens the popup. The behavior of the datepicker is the same as if the parameter AllowInput is set to false, so a click on the inputfield toggles the popup.

After some research I found out that in the javascript function 'createDatePicker' (https://github.com/radzenhq/radzen-blazor/blob/master/Radzen.Blazor/wwwroot/Radzen.Blazor.js#L1018) a handler is added to the button and the input in the datepicker which still exists after a rerender. I think this is the source of the problem I'm facing right now.

Can you re-open the ticket and fix this? Thanks in advance.