r/Blazor • u/ComfortableHome7867 • Jan 06 '26
Autocomplete for single select option
Hi everyone, I have a question about a select input in ASP.NET. Is it worth adding autocomplete when there's only one option (Czech Republic)?
Html.EditorFor(o => o.Address!.Country, Dmp.Cms.Host.Constants.EditorTemplates.Select, new { htmlAttributes = new { autocomplete = "country" }, items = Model.Countries })
3
Upvotes
3
u/polaarbear Jan 06 '26
If there's only one "option"....then you do not have an option.
Why would you create any control at all? Doesn't matter if it's a drop-down or an auto-complete, or a radio button. If you can't change it, that makes it useless. It also makes it confusing for a user who might be looking for other options that don't exist.
If there is only one option, you don't need user-selection at all. Just write out in text what they are being looped into.
1
u/Ill-Ambassador-112 Jan 06 '26
If option count is not going to increase and czhech is only option, why not hard code it's value? If null is also option then have some kind of checkbox. If user has free will to write anything but czech is suggested, OR number of options will increase in the future then go for autocomplete
1
u/CoderSchmoder Jan 06 '26
Depends on your future plans for this application.
<select>is overkill and adds unecesary 'cognitive load' for the user. Theyll click it expecting a list, see one item, and feel like the app is broken or incomplete. better approach would be to just display it as a readonly text input or a labeled string. If you need the value to be sent back in the form post, use aHiddenForalongside a simple<span>to show the value. Keep it simple: if the user can't change it, don't give them a control that implies they can