Fix Yomitan popup shortcut precedence in keyboard-only mode (#61)

This commit is contained in:
2026-05-04 00:06:06 -07:00
committed by GitHub
parent 0915b23dc8
commit 30712738dc
4 changed files with 94 additions and 1 deletions
+34
View File
@@ -613,6 +613,40 @@ test('keyboard mode: up/down/j/k forward keydown to yomitan popup when open', as
}
});
test('keyboard mode: popup keybinds take precedence over configured session bindings', async () => {
const { ctx, handlers, testGlobals } = createKeyboardHandlerHarness();
try {
await handlers.setupMpvInputForwarding();
handlers.updateSessionBindings([
{
sourcePath: 'keybindings[0].key',
originalKey: 'KeyJ',
key: { code: 'KeyJ', modifiers: [] },
actionType: 'mpv-command',
command: ['cycle', 'sid'],
},
] as never);
handlers.handleKeyboardModeToggleRequested();
ctx.state.yomitanPopupVisible = true;
testGlobals.setPopupVisible(true);
testGlobals.dispatchKeydown({ key: 'j', code: 'KeyJ' });
assert.deepEqual(testGlobals.mpvCommands, []);
assert.deepEqual(
testGlobals.commandEvents
.filter((event) => event.type === 'forwardKeyDown')
.map((event) => event.code),
['KeyJ'],
);
} finally {
ctx.state.keyboardDrivenModeEnabled = false;
testGlobals.restore();
}
});
test('keyboard mode: repeated popup navigation keys are forwarded while popup is open', async () => {
const { ctx, handlers, testGlobals } = createKeyboardHandlerHarness();