diff --git a/src/event/behavior/keydown.ts b/src/event/behavior/keydown.ts
index 6927deef..1305ca0c 100644
--- a/src/event/behavior/keydown.ts
+++ b/src/event/behavior/keydown.ts
@@ -28,7 +28,7 @@ const keydownBehavior: {
ArrowDown: (event, target, instance) => {
/* istanbul ignore else */
if (isElementType(target, 'input', {type: 'radio'} as const)) {
- return () => walkRadio(instance, target, -1)
+ return () => walkRadio(instance, target, 1)
}
},
ArrowLeft: (event, target, instance) => {
@@ -46,7 +46,7 @@ const keydownBehavior: {
ArrowUp: (event, target, instance) => {
/* istanbul ignore else */
if (isElementType(target, 'input', {type: 'radio'} as const)) {
- return () => walkRadio(instance, target, 1)
+ return () => walkRadio(instance, target, -1)
}
},
Backspace: (event, target, instance) => {
diff --git a/src/event/radio.ts b/src/event/radio.ts
index 7c374af9..2d76fc04 100644
--- a/src/event/radio.ts
+++ b/src/event/radio.ts
@@ -28,5 +28,6 @@ export function walkRadio(
focusElement(group[i])
instance.dispatchUIEvent(group[i], 'click')
+ return
}
}
diff --git a/tests/event/behavior/keydown.ts b/tests/event/behavior/keydown.ts
index 42feb6c0..bca55c3b 100644
--- a/tests/event/behavior/keydown.ts
+++ b/tests/event/behavior/keydown.ts
@@ -317,7 +317,9 @@ cases(
-
+
+
+
`,
{focus},
@@ -360,14 +362,14 @@ cases(
expectedTarget: '//input[@value="a"]',
},
'forward around the corner': {
- focus: '//input[@value="d"]',
+ focus: '//input[@value="e"]',
key: 'ArrowRight',
expectedTarget: '//input[@value="a"]',
},
'backward around the corner': {
focus: '//input[@value="a"]',
key: 'ArrowUp',
- expectedTarget: '//input[@value="d"]',
+ expectedTarget: '//input[@value="e"]',
},
'do nothing on single radio': {
focus: '//input[@name="solo"]',
@@ -378,5 +380,10 @@ cases(
key: 'ArrowRight',
expectedTarget: '//input[@value="nameless2"]',
},
+ 'on radios with aria-disabled': {
+ focus: '//input[@value="d"]',
+ key: 'ArrowDown',
+ expectedTarget: '//input[@value="f"]',
+ },
},
)