Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

fix(autocomplete): always set tabindex to allow receiving focus. #6135

Closed

Conversation

devversion
Copy link
Member

At the moment we only set the tabindex if we specify a tabindex attribute.

That's why the autocomplete won't receive focus on sidenav autofocus.

Closes #6101 Fixes #5665

Please review @jelbourn

if (attr.hasOwnProperty('tabindex')) {
element.attr('tabindex', '-1');
}
element.attr('tabindex', '-1');
Copy link
Member

Choose a reason for hiding this comment

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

It looks like someone originally went to do the right thing and forgot a !. It should be:

    if (!attrs['tabindex']) {
      $element.attr('tabindex', '-1');
    }

@devversion devversion force-pushed the fix/autocomplete-receive-focus branch 2 times, most recently from 94ebebb to f8fcbb2 Compare December 7, 2015 21:48
@@ -98,6 +98,31 @@ describe('<md-autocomplete>', function() {
element.remove();
}));

it('should allow receiving focus on the autocomplete', function() {
var scope = createScope(null, {inputId: 'custom-input-id'});
var template = '\
Copy link
Member

Choose a reason for hiding this comment

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

Prefer string concatenation instead of using \

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm just trying my best in using the best code conventions. The tests above also use \.
But I will use string concatenation, because you wish that 😄

Copy link
Member

Choose a reason for hiding this comment

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

Yeah- typically good, but I've been hoping to eliminate the \ stuff over time.

Copy link
Member Author

Choose a reason for hiding this comment

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

Great, I will remember that

@devversion devversion force-pushed the fix/autocomplete-receive-focus branch from f8fcbb2 to 825cd9c Compare December 7, 2015 22:28
@devversion
Copy link
Member Author

Used your suggestions now @jelbourn

@jelbourn jelbourn added the pr: merge ready This PR is ready for a caretaker to review label Dec 7, 2015
@jelbourn jelbourn closed this in d3c0acb Dec 8, 2015
@devversion devversion deleted the fix/autocomplete-receive-focus branch April 21, 2016 11:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr: merge ready This PR is ready for a caretaker to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants