Skip to content
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

fix(ui5-split-button): correct focus behavior #7320

Closed
wants to merge 1 commit into from
Closed

Conversation

hinzzx
Copy link
Contributor

@hinzzx hinzzx commented Jul 12, 2023

WIP & Ongoing discussions

Fixes: #7281

@unazko unazko self-requested a review July 12, 2023 11:13
Copy link
Contributor

@unazko unazko left a comment

Choose a reason for hiding this comment

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

I suggest to have a discussion with architects about this refactoring as it is easily possible to achieve a blocking behavior with the component initial implementation.
For example if we were to retrieve the focus to the root component element each time we press the arrow or the text button we'll receive a rerendering operation. Therefore if we press the text button and then the arrow button multiple times we'll receive a DOM blocking behavior.
The problem is that we do want to retrieve the focus to the root element for each individual button press.

this._shiftOrEscapePressed = false;
this.focused = true;
}

_singleButtonFocusIn(e: FocusEvent) {
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.

@@ -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.

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.

@github-actions github-actions bot added the Stale label Aug 16, 2023
@github-actions github-actions bot closed this Aug 23, 2023
@nnaydenow nnaydenow deleted the spltbtn-focus-fix branch October 20, 2023 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SplitButton]: multiple focus outlines visible on primary btn click
2 participants