mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-02 03:57:38 +08:00
feat(module: icon): icon role attribute change now assignable, does not change default behavior (#3370)
when a screen reader parses an icon, it sees the role attribute has a value of 'img'. in the case where we don't want the screen reader to read the icon, the role can be assigned a blank value and the role attribute will not be added. instead, the aria-hidden attribute will be added with a value of 'true' no breaking changes
This commit is contained in:
parent
679a83410a
commit
c559bd321e
@ -1,7 +1,7 @@
|
||||
@namespace AntDesign
|
||||
@inherits AntDomComponentBase
|
||||
|
||||
<span role="img" alt="@Alt" class="@ClassMapper.Class" style="@Style" id="@Id" tabindex="@TabIndex" @ref="Ref" @attributes="_attributes" @onclick:stopPropagation="StopPropagation">
|
||||
<span class="@ClassMapper.Class" style="@Style" id="@Id" tabindex="@TabIndex" @ref="Ref" @attributes="_attributes" @onclick:stopPropagation="StopPropagation">
|
||||
@if (Component == null)
|
||||
{
|
||||
@((MarkupString) _svgImg)
|
||||
|
@ -11,6 +11,12 @@ namespace AntDesign
|
||||
[Parameter]
|
||||
public string Alt { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string Role { get; set; } = "img";
|
||||
|
||||
[Parameter]
|
||||
public string AriaLabel { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool Spin { get; set; }
|
||||
|
||||
@ -91,6 +97,22 @@ namespace AntDesign
|
||||
_attributes.Add("onclick", (Delegate)HandleOnClick);
|
||||
}
|
||||
|
||||
_attributes.Add("aria-label", AriaLabel);
|
||||
|
||||
if (String.IsNullOrEmpty(Role))
|
||||
{
|
||||
_attributes.Add("aria-hidden", "true");
|
||||
}
|
||||
else
|
||||
{
|
||||
_attributes.Add("role", Role);
|
||||
}
|
||||
|
||||
if (Role == "img")
|
||||
{
|
||||
_attributes.Add("alt", Alt);
|
||||
}
|
||||
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user