Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions coral-base-button/src/scripts/BaseButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,11 @@ const BaseButton = (superClass) => class extends BaseLabellable(superClass) {
// Update autoAriaLabel as well
iconElement.autoAriaLabel = iconAutoAriaLabelValue;

// Accessibility fix
// If the wrapping <button> has either a "title=" or an "icon=" attribute
// passes the value down to the <coral-icon> as "alt="
(this.title || this.icon) && (iconElement.alt = this.title || this.icon);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this case is only valid when button itself does not have any text content in it, secondly this code can be avoided by setting iconAutoAriaLabel to Icon.autoAriaLabel.ON

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the icon attribute doesn't seem like it would ever be satisfactory alt text. Looking at the list of icons these are not suitable as alt text. Perhaps as a fallback you could space separate instead of camel case - but even then these wouldn't be localized so it would still seem like a bad idea.


// removes the icon element from the DOM.
if (this.icon === '') {
iconElement.remove();
Expand Down