mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-04 00:41:33 -07:00
Fix Yomitan popup shortcut precedence in keyboard-only mode (#61)
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -865,7 +865,7 @@ export function createKeyboardHandlers(
|
||||
if (modifierOnlyCodes.has(e.code)) return false;
|
||||
|
||||
const keyString = keyEventToString(e);
|
||||
if (ctx.state.sessionBindingMap.has(keyString)) {
|
||||
if (!ctx.state.keyboardDrivenModeEnabled && ctx.state.sessionBindingMap.has(keyString)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user