-
Notifications
You must be signed in to change notification settings - Fork 11
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: Off by one error in next/previous tab #15
Changes from 1 commit
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 |
---|---|---|
|
@@ -23,4 +23,7 @@ | |
"autoFix": true | ||
}, | ||
], | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": true | ||
}, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/// <reference types="cypress"/> | ||
/* global cy */ | ||
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.
|
||
|
||
// const { _ } = Cypress | ||
|
||
|
@@ -93,6 +94,16 @@ describe('form test', () => { | |
cy.get('body').should(beFocused) | ||
}) | ||
|
||
it('moves focus back to the first element when the last element is focused', () => { | ||
cy.get('a:last').tab() | ||
cy.get('a:first').should(beFocused) | ||
}) | ||
|
||
it('moves focus back to the first element when the last element is focused', () => { | ||
cy.get('a:first').tab({ shift: true }) | ||
cy.get('a:last').should(beFocused) | ||
}) | ||
|
||
describe('events', () => { | ||
beforeEach(() => { | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/* global Cypress, cy */ | ||
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.
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. are you sure you are using local install of eslint? the cypress plugin should have these globals set |
||
const tabSequence = require('ally.js/query/tabsequence') | ||
|
||
const { _, Promise } = Cypress | ||
|
@@ -75,22 +76,14 @@ const performTab = (el, options) => { | |
|
||
const nextItemFromIndex = (i, seq, reverse) => { | ||
if (reverse) { | ||
if (i === 0 || i === -1) { | ||
i = seq.length | ||
} | ||
} else { | ||
if (i === seq.length) { | ||
i = 0 | ||
} | ||
const nextIndex = i <= 0 ? seq.length - 1 : i - 1 | ||
|
||
return seq[nextIndex] | ||
} | ||
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. lint rules prevented an |
||
// } | ||
|
||
if (reverse) { | ||
return seq[i - 1] | ||
} | ||
const nextIndex = i === seq.length - 1 ? 0 : i + 1 | ||
|
||
return seq[i + 1] | ||
return seq[nextIndex] | ||
} | ||
|
||
const tabKeyEventPartial = { | ||
|
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.
The ESLint plugin insisted on this change (added every time I removed it).
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.
interesting, I will keep it then