havit / Havit.Blazor

Free Bootstrap 5 components for ASP.NET Blazor + optional enterprise-level stack for Blazor development (gRPC code-first, layered architecture, localization, auth, ...)
https://havit.blazor.eu
MIT License
486 stars 67 forks source link

[HxInputBase] Unable to control `id` attribute for input-components #843

Open hakenr opened 3 months ago

hakenr commented 3 months ago

Currently, there's no way to control the id attribute for input. The protected InputId { get; private set; } property is set to a random (GUID-based) ID by the EnsureInputId() method, which is called only when the Label is rendered.

When there is no Label, no id is rendered. There is no way to set your own id, and the id from AdditionalAttributes is ignored (even if InputId is not set). Some derived components with complex structures (such as InputDate) have different logic for handling the id.

If it turns out that the id should be controllable, we should consolidate the related logic. (We should probably respect the id set from InputBase.AdditionalAttributes?)