-
Notifications
You must be signed in to change notification settings - Fork 278
fix(ui5-split-button): correct focus behavior #7320
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -278,7 +278,6 @@ class SplitButton extends UI5Element { | |
const handleTouchStartEvent = () => { | ||
this._textButtonActive = true; | ||
this.focused = false; | ||
this._setTabIndexValue(); | ||
}; | ||
|
||
this._textButtonPress = { | ||
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could react in the |
||
e.preventDefault(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could add: |
||
(e.target! as Button).focused = false; | ||
} | ||
|
||
_onKeyDown(e: KeyboardEvent) { | ||
if (isDown(e) || isUp(e) || isDownAlt(e) || isUpAlt(e) || isF4(e)) { | ||
e.preventDefault(); | ||
|
@@ -329,8 +335,6 @@ class SplitButton extends UI5Element { | |
this._shiftOrEscapePressed = true; | ||
this._textButtonActive = false; | ||
} | ||
|
||
this._setTabIndexValue(); | ||
} | ||
|
||
_onKeyUp(e: KeyboardEvent) { | ||
|
@@ -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; | ||
} | ||
|
||
|
@@ -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() { | ||
|
There was a problem hiding this comment.
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.