Fix null ref when hitting Enter to add an ingredient using the IngredientListEditor
Closed this issue · 0 comments
danroth27 commented
When hitting Enter to add an ingredient:
Uncaught TypeError: Cannot read properties of null (reading 'click')
at HTMLDivElement.onkeypress (submit:1:136)
<div onkeypress="@onEnterClickNextButton">
<InputText placeholder="Example: 350g flour" @bind-Value="@newIngredientText" />
<button type="button" @onclick="AddIngredient">Add</button>
</div>
string onEnterClickNextButton = "if (event.code === 'Enter') { event.preventDefault(); event.target.dispatchEvent(new Event('change')); event.target.nextElementSibling.click(); }";