Skip to content
Closed
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions packages/main/src/SplitButton.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@touchstart={{_textButtonPress}}
@mousedown={{_textButtonPress}}
@mouseup={{_textButtonRelease}}
@focusin={{_setTabIndexValue}}
@focusin={{_singleButtonFocusIn}}
@focusout={{_onFocusOut}}
>
{{#if isTextButton}}
Expand All @@ -43,7 +43,7 @@
aria-expanded="{{accessibilityInfo.ariaExpanded}}"
aria-haspopup="{{accessibilityInfo.ariaHaspopup}}"
@click="{{_fireArrowClick}}"
@focusin={{_setTabIndexValue}}
@focusin={{_singleButtonFocusIn}}
@focusout={{_onFocusOut}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Think that we shouldn't react on focus out of the arrow button as we do not expect to have it focused on the first place.
The same would apply for the text button.

>
</ui5-button>
Expand Down
26 changes: 10 additions & 16 deletions packages/main/src/SplitButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ class SplitButton extends UI5Element {
const handleTouchStartEvent = () => {
this._textButtonActive = true;
this.focused = false;
this._setTabIndexValue();
};

this._textButtonPress = {
Expand All @@ -300,17 +299,24 @@ class SplitButton extends UI5Element {
}
this._shiftOrEscapePressed = false;
this.focused = false;
this._setTabIndexValue();
}

_onFocusIn(e: FocusEvent) {
if (this.disabled || getEventMark(e)) {
return;
}
if (!(e.target! as HTMLElement).classList.contains("ui5-split-button-root")) {
return;
}
this._shiftOrEscapePressed = false;
this.focused = true;
}

_singleButtonFocusIn(e: FocusEvent) {
Copy link
Contributor

@unazko unazko Jul 18, 2023

Choose a reason for hiding this comment

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

We could react in the _onFocusIn Instead of reacting on focus in for the text and arrow buttons separately.
That way we could remove that attached handlers for focusin and focusout for the arrow and text buttons.
In both cases we want to place the focus back to the container element.

e.preventDefault();
Copy link
Contributor

Choose a reason for hiding this comment

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

We could add:
this.focused = true;
as the focus should be maintained over the split button container, when we click over the text or the arrow button.

(e.target! as Button).focused = false;
}

_onKeyDown(e: KeyboardEvent) {
if (isDown(e) || isUp(e) || isDownAlt(e) || isUpAlt(e) || isF4(e)) {
e.preventDefault();
Expand All @@ -329,8 +335,6 @@ class SplitButton extends UI5Element {
this._shiftOrEscapePressed = true;
this._textButtonActive = false;
}

this._setTabIndexValue();
}

_onKeyUp(e: KeyboardEvent) {
Expand All @@ -345,15 +349,14 @@ class SplitButton extends UI5Element {
this._spacePressed = false;
}
}

this._setTabIndexValue();
}

_fireClick(e?: Event) {
e?.stopPropagation();
if (!this._shiftOrEscapePressed) {
this.fireEvent("click");
}
this.textButton!.focused = false;
this._shiftOrEscapePressed = false;
}

Expand All @@ -363,18 +366,9 @@ class SplitButton extends UI5Element {
}

_textButtonRelease() {
this.textButton!.focused = false;
this._textButtonActive = false;
this._textButtonIcon = this.textButton && this.activeIcon !== "" && (this._textButtonActive) && !this._shiftOrEscapePressed ? this.activeIcon : this.icon;
this._setTabIndexValue();
}

_setTabIndexValue() {
const textButton = this.textButton,
arrowButton = this.arrowButton,
buttonsAction = (textButton && (textButton.focused || textButton.active))
|| (arrowButton && (arrowButton.focused || arrowButton.active));

this._tabIndex = this.disabled || buttonsAction ? "-1" : "0";
}

get textButtonAccText() {
Expand Down
31 changes: 5 additions & 26 deletions packages/main/src/themes/SplitButton.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
outline: 0;
}

.ui5-split-arrow-button:focus,
.ui5-split-text-button:focus {
outline: 0;
}

:host([focused]) .ui5-split-button-root:after {
content: "";
position: absolute;
Expand Down Expand Up @@ -181,30 +186,4 @@

[dir="rtl"] .ui5-split-arrow-button {
border-radius: var(--_ui5_button_border_radius) 0 0 var(--_ui5_button_border_radius);
}



.ui5-split-arrow-button[focused]::part(button)::after {
border-top-left-radius: var(--_ui5_split_button_inner_focused_border_radius_inner);
border-bottom-left-radius: var(--_ui5_split_button_inner_focused_border_radius_inner);
}

.ui5-split-text-button[focused]::part(button)::after {
border-top-right-radius: var(--_ui5_split_button_inner_focused_border_radius_inner);
border-bottom-right-radius: var(--_ui5_split_button_inner_focused_border_radius_inner);
}

[dir="rtl"] .ui5-split-arrow-button[focused]::part(button)::after {
border-top-left-radius: var(--_ui5_split_button_inner_focused_border_radius_outer);
border-bottom-left-radius: var(--_ui5_split_button_inner_focused_border_radius_outer);
border-top-right-radius: var(--_ui5_split_button_inner_focused_border_radius_inner);
border-bottom-right-radius: var(--_ui5_split_button_inner_focused_border_radius_inner);
}

.ui5-split-text-button[dir="rtl"][focused]::part(button)::after {
border-top-left-radius: var(--_ui5_split_button_inner_focused_border_radius_inner);
border-bottom-left-radius: var(--_ui5_split_button_inner_focused_border_radius_inner);
border-top-right-radius: var(--_ui5_split_button_inner_focused_border_radius_outer);
border-bottom-right-radius: var(--_ui5_split_button_inner_focused_border_radius_outer);
}