Skip to content

Commit

Permalink
Checks if there is actually a descendant or not
Browse files Browse the repository at this point in the history
Fixes #737
  • Loading branch information
jbalsas committed May 18, 2017
1 parent a1a894c commit c7ba9c7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ui/react/src/components/base/widget-focus-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@
*/
focus: function(event) {
if (!event || this._isValidTarget(event.target)) {
if (this._descendants) {
if (this._descendants && this._descendants.length) {
var activeDescendantEl = this._descendants[this._activeDescendant];
// When user clicks with the mouse, the activeElement is already set and there
// is no need to focus it. Focusing of the active descendant (usually some button) is required
// in case of keyboard navigation, because the focused element might be not the first button,
// but the div element, which contains the button.
if (activeDescendantEl && document.activeElement !== activeDescendantEl && !this.props.focusFirstChild) {
if (document.activeElement !== activeDescendantEl && !this.props.focusFirstChild) {
if (this._descendants.indexOf(document.activeElement) === -1) {
activeDescendantEl.focus();
}
Expand Down

0 comments on commit c7ba9c7

Please sign in to comment.