feat: permanently delete archived lists
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { nextDialogFocusIndex } from './list-purge'
|
||||
|
||||
describe('archived list purge dialog behavior', () => {
|
||||
it('wraps Tab focus between the cancel and destructive actions', () => {
|
||||
expect(nextDialogFocusIndex(0, 2, true)).toBe(1)
|
||||
expect(nextDialogFocusIndex(1, 2, false)).toBe(0)
|
||||
})
|
||||
|
||||
it('leaves focus alone while moving between interior controls', () => {
|
||||
expect(nextDialogFocusIndex(1, 3, true)).toBeNull()
|
||||
expect(nextDialogFocusIndex(1, 3, false)).toBeNull()
|
||||
expect(nextDialogFocusIndex(0, 0, false)).toBeNull()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,6 @@
|
||||
export function nextDialogFocusIndex(currentIndex: number, controlCount: number, shiftKey: boolean) {
|
||||
if (controlCount < 2) return null
|
||||
if (shiftKey && currentIndex === 0) return controlCount - 1
|
||||
if (!shiftKey && currentIndex === controlCount - 1) return 0
|
||||
return null
|
||||
}
|
||||
Reference in New Issue
Block a user