Skip to content

feat(ui5-ai-button): improve acc attributes #11929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

GDamyanov
Copy link
Contributor

Improve acc attributes for ui5-ai-button component

@GDamyanov GDamyanov self-assigned this Jul 16, 2025
const ariaLabel = `${this._leftButtonTooltipText} ${(attrLabel?.concat(labelRefTexts) || "")}`.trim();

return {
hasPopup: hasPopup ?? (this._hideArrowButton ? "false" : "menu"),
Copy link
Contributor

Choose a reason for hiding this comment

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

hasPopup || "false" to use the provided by the application dev value directly.

getAssociatedLabelForTexts(this) ||
"";

const ariaLabel = `${this._leftButtonTooltipText} ${(attrLabel?.concat(labelRefTexts) || "")}`.trim();
Copy link
Contributor

Choose a reason for hiding this comment

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

${this._leftButtonTooltipText} ${labelRefTexts}.trim();


get _computedAccessibilityAttributes(): AIButtonAccesibilityAttributes {
const {
ariaLabel: attrLabel,
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure we need to provide ariaLabel in the accessibility attributes of the button for now. The tooltip text is already made to be part of the aira-label attribute value.

@@ -28,31 +31,35 @@ export default function SplitButtonTemplate(this: SplitButton) {
onMouseUp={this._textButtonRelease}
onFocusIn={this._onInnerButtonFocusIn}
onFocusOut={this._onFocusOut}
title={this.accessibilityAttributes.ariaLabel}
tooltip={this.accessibilityAttributes.ariaLabel}
Copy link
Contributor

Choose a reason for hiding this comment

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

Only tooltip attribute is needed. There is no title property.
Something like tooltip={this.accInfo.root.title}. We need to adjust the accInfo method so that root.title is present.

@@ -9,6 +9,9 @@ export default function SplitButtonTemplate(this: SplitButton) {
class="ui5-split-button-root"
tabindex={this._tabIndex}
aria-labelledby={`${this._id}-invisibleTextDefault ${this._id}-invisibleText`}
aria-haspopup={this.accessibilityAttributes.hasPopup}
Copy link
Contributor

Choose a reason for hiding this comment

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

it will be good to use the accInfo method here as well.
aria-haspopup={this.accInfo.root.hasPopup}
aria-label={this.accInfo.root.ariaLabel}
aria-label={this.accInfo.root.roleDescription}

@@ -35,6 +36,8 @@ import SplitButtonTemplate from "./SplitButtonTemplate.js";
// Styles
import SplitButtonCss from "./generated/themes/SplitButton.css.js";

type SplitButtonAccessibilityAttributes = Pick<AccessibilityAttributes, "hasPopup" | "ariaRoleDescription" | "ariaLabel">;
Copy link
Contributor

Choose a reason for hiding this comment

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

We might need to have something like:
type SplitButtonRootA11yAttributes = Pick<AccessibilityAttributes, "hasPopup" | "ariaRoleDescription">;

type SplitButtonAccessibilityAttributes = { root?: SplitButtonRootA11yAttributes, arrowButton?: SplitButtonRootA11yAttributes, }

@@ -12,6 +12,7 @@ export default function ButtonTemplate(this: Button) {
_hideArrowButton={this._hideArrowButton}
onClick={this._onClick}
onArrowClick={this._onArrowClick}
accessibilityAttributes={this._computedAccessibilityAttributes}
Copy link
Contributor

@unazko unazko Jul 18, 2025

Choose a reason for hiding this comment

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

And for this to work we might want to split the ai accessibility attributes like this { root: {}, arrowButton: {} } similar to the same property in the ui5-split-button.
Depending on the use case the application developer could set aria-haspoup="menu" to the root button or to the arrow button.

@@ -183,6 +205,10 @@ class Button extends UI5Element {
return !!this._stateText;
}

get _leftButtonTooltipText() {
return this._hasText ? Button.i18nBundle.getText(BUTTON_TOOLTIP_TEXT, this._stateText as string) : "";
Copy link
Contributor

Choose a reason for hiding this comment

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

We can directly store and use this as a variable in the _computedAccessibilityAttributes.
Don't think we need this method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants