Please see attached screenshots. This behavior came after updating to version 4.7.0
`
<BlazoredTypeahead SearchMethod="SearchCDMS"
MinimumLength="1" Debounce="1000" placeholder="start typing to get results..."
@bind-Value="selectedItem">
I can confirm this issue occurs together with Blazored.Modal 7.0.0. I am unable to type text in the Typeahead box as the characters I type/paste are immediately removed.
I've brought my modal code down to a minimum (typeahead box only, static list of results), which does not fix the issue.
The dropdown function with the arrow down button does work.
It works fine when using Typeahead outside modal dialogs.
Reverting Blazored.Modal back to 6.0.1 fixes the issue inside modal dialogs.
~Later I will attempt to set up a minimal reproduction sample.~
Edit: I cannot reproduce it in a minimal reproduction sample. I will follow up by rechecking the (updated?) package setup requirements and further stripping down my solution. I also suspect it has something to do with the solution template initially started with .net5 and I might have missed an upgrade step.
Can confirm I see the same issue with Blazored.Modal 7.0.0 and Typeahead 4.7.0.
Though this is my first use of Typeahead and I might be doing something wrong.
I don't know if I started from net5.0 template anymore but I am going to check the.
I did some more digging. Compared my app to the net6.0 blazor Server app template and found no significant differences besides what I added for my app.
Tried with a new minimal reproduceable example but just like @BeyondDefinition could not reproduce the issue.
Will try to copy my code into a clean repo and see if it works then...
I could actually narrow it down to the BlazoredModalIstance being passed to the Modal content as [CascadingParameter]
Trying this minimal example I could reproduce the issue
The component Initialize() Method is called everytime in OnParameterSet() but this method can fire multiple times, even when the component is active.
It seems that including
[CascadingParameter]
public BlazoredModalInstance? ModalInstance { get; set; }
is creating such a condition, where the parameter will bubble down and the OnParametersSet() Method is called after every input.
I think the necessity of the Initialize call should be looked at and it needs to be prevented to fire repeatedly after the component has been initialized already.
I'd like to mention that with Blazored.Modal v7.0.0 the OnParametersSet in Typeahead is probably (indirectly) triggered after every input because the setter of [CascadingParameter] ModalInstance is called every time you type a letter, which was not the case with v6.0.1. The setter is even triggered for changes on a regular InputText or input, with or without value binding.
Is there a way to identify why that happens? The call stack in the setter is kinda useless. Step out doesn't work. I tried setting various breakpoints in Blazored.Modal but that didn't get me closer to the answer.
If preferred I can report this issue separately on Blazored.Modal.
Good question.
I don't know if that is the desired behaviour on Blazored.Modal side or not.
But in any case a component should be able to handle multiple calls to OnParametersSet() gracefully without affecting current user input as there are countless other situations that can trigger it.
I figured out what is causing the frequent rerenders of BlazoredModal.
Apparently the onkeyup and onkeydown handlers in FocusTrap sets the CascadedValue every time any keyup/keydown DOM event is generated in a child component, which rerenders the component twice for every letter, causing OnParametersSet to be called in Typeahead. If you remove these 2 event handlers, the Typeahead component also works as intended.
I'm not sure if this needs to be fixed, but it does seem to generate some overhead. Perhaps it's possible to disable event propagation. What is your opinion?
Please see attached screenshots. This behavior came after updating to version 4.7.0
`
Have you seen the discussion here?
Others have reported similar issues but it's always turned out to be a fix in their code base.
@chrissainty I have same issue after updating Blazored.Modal from 6.0.1 to 7.0.0 right now. Typeahead was 4.7.0 for long time and worked good.
I can confirm this issue occurs together with Blazored.Modal 7.0.0. I am unable to type text in the Typeahead box as the characters I type/paste are immediately removed.
~Later I will attempt to set up a minimal reproduction sample.~
Edit: I cannot reproduce it in a minimal reproduction sample. I will follow up by rechecking the (updated?) package setup requirements and further stripping down my solution. I also suspect it has something to do with the solution template initially started with .net5 and I might have missed an upgrade step.
Can confirm I see the same issue with Blazored.Modal 7.0.0 and Typeahead 4.7.0. Though this is my first use of Typeahead and I might be doing something wrong.
I don't know if I started from net5.0 template anymore but I am going to check the.
I did some more digging. Compared my app to the net6.0 blazor Server app template and found no significant differences besides what I added for my app. Tried with a new minimal reproduceable example but just like @BeyondDefinition could not reproduce the issue.
Will try to copy my code into a clean repo and see if it works then...
I could actually narrow it down to the
BlazoredModalIstance
being passed to the Modal content as[CascadingParameter]
Trying this minimal example I could reproduce the issueIf you remove
Typeahead performs as expected.
Edit: Going back to Typeahead 4.6.0 solves this issue entirely as well as going back to Modal 6.0.1
Looking at the changes from #217 the problem is rather obvious:
The component
Initialize()
Method is called everytime inOnParameterSet()
but this method can fire multiple times, even when the component is active. It seems that includingis creating such a condition, where the parameter will bubble down and the
OnParametersSet()
Method is called after every input.I think the necessity of the Initialize call should be looked at and it needs to be prevented to fire repeatedly after the component has been initialized already.
Thanks @SSchulze1989 for your insights.
I'd like to mention that with Blazored.Modal v7.0.0 the
OnParametersSet
in Typeahead is probably (indirectly) triggered after every input because the setter of[CascadingParameter] ModalInstance
is called every time you type a letter, which was not the case with v6.0.1. The setter is even triggered for changes on a regular InputText or input, with or without value binding.Is there a way to identify why that happens? The call stack in the setter is kinda useless. Step out doesn't work. I tried setting various breakpoints in Blazored.Modal but that didn't get me closer to the answer.
If preferred I can report this issue separately on Blazored.Modal.
Good question. I don't know if that is the desired behaviour on Blazored.Modal side or not.
But in any case a component should be able to handle multiple calls to
OnParametersSet()
gracefully without affecting current user input as there are countless other situations that can trigger it.Opened a pr that should fix this issue without affecting the one where the selected value would not disappear after being set from outside.
Great job!
I figured out what is causing the frequent rerenders of BlazoredModal. Apparently the
onkeyup
andonkeydown
handlers in FocusTrap sets the CascadedValue every time anykeyup
/keydown
DOM event is generated in a child component, which rerenders the component twice for every letter, causingOnParametersSet
to be called in Typeahead. If you remove these 2 event handlers, the Typeahead component also works as intended.I'm not sure if this needs to be fixed, but it does seem to generate some overhead. Perhaps it's possible to disable event propagation. What is your opinion?
Also may be this make v7 much slower than 6.0.1. On previouse version modals closing instantly and on latest they have delay like 0.5 second.
I think this is a separate issue and should definitely be tracked on the Blazored.Modam side.
That is by design in v7.
Agreed, see https://github.com/Blazored/Modal/issues/459