Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

Skip disabled items while navigating with keyboard #1823

Closed
wants to merge 1 commit into from
Closed

Skip disabled items while navigating with keyboard #1823

wants to merge 1 commit into from

Conversation

vilnytskyi
Copy link

When user presses up/down keys within dropdown, disabled items become active too. It has no visual effect but still is a bit confusing. I have added check for disabled items insted of plain incrementing/decrementing activeIndex value.

else if (ctrl.activeIndex < ctrl.items.length - 1) {
var newIndex = ctrl.activeIndex + 1;
while (_isItemDisabled(ctrl.items[newIndex]) && newIndex < ctrl.items.length)
newIndex++;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we increment and compare in the while expression? To save repeating the condition inside it.

else if (ctrl.activeIndex > 0 || (ctrl.search.length === 0 && ctrl.tagging.isActivated && ctrl.activeIndex > -1)) {
var newIndex = ctrl.activeIndex - 1;
while (_isItemDisabled(ctrl.items[newIndex]) && newIndex >= 0)
newIndex--;
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to the other comment, to save on duplication of checks

@user378230
Copy link
Contributor

@Seprum this looks very useful! But it does need unit tests before it can be merged. 😥

Any chance you could add some? 😃

@user378230
Copy link
Contributor

user378230 commented Nov 7, 2016

@Jefiozie you might like to pick this one up with tests etc. if you feel like it. I think it seems like a reasonable change.

@Jefiozie
Copy link
Contributor

Jefiozie commented Nov 8, 2016

@user378230 , you want me to implement this fix?

@user378230
Copy link
Contributor

user378230 commented Nov 8, 2016

@Jefiozie Only if you want to! It looks fairly easy and makes sense, so thought you might like it 😝

(You can just open a new PR)

@Jefiozie
Copy link
Contributor

@user378230 , see my PR 👍

@Jefiozie
Copy link
Contributor

Closing pr as handeld by other PR

@Jefiozie Jefiozie closed this Apr 26, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants