Skip to content

fix(ui5-shellbar-branding): space key now triggers click event#13686

Open
PetyaMarkovaBogdanova wants to merge 8 commits into
mainfrom
fix-shellbar-branding-click-2
Open

fix(ui5-shellbar-branding): space key now triggers click event#13686
PetyaMarkovaBogdanova wants to merge 8 commits into
mainfrom
fix-shellbar-branding-click-2

Conversation

@PetyaMarkovaBogdanova

Copy link
Copy Markdown
Contributor

"Space" key now triggers "click" event on Shellbar Branding.

@sap-ui5-webcomponents-release

sap-ui5-webcomponents-release Bot commented Jun 12, 2026

Copy link
Copy Markdown

it("fires click event on Enter and Space", () => {
basicTemplate();

cy.get("#shellbarBranding").then(branding => {

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.

You can use the attribute selector instead of the id selector.

Comment on lines 148 to 169
_onkeydown(e: KeyboardEvent) {
if (isSpace(e)) {
if (isEnter(e) && !this.href) {
this._activate(e);
e.preventDefault();
} else if (isSpace(e)) {
e.preventDefault();
}
}

_onkeyup(e: KeyboardEvent) {
if (!isSpace(e)) {
return;
}

if (isEnter(e)) {
this._fireClick();
this._activate(e);

if (this.href && !e.defaultPrevented) {
const customEvent = new MouseEvent("click");
customEvent.stopImmediatePropagation();
this.getDomRef()!.dispatchEvent(customEvent);
}
}

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.

The && !this.href guard on Enter prevents ui5-click from firing when href is set. The getDomRef().dispatchEvent(new MouseEvent("click")) for Space+href navigation has no effect since the click is dispatched on the host element, not the inner .

…bcomponents into fix-shellbar-branding-click-2
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