Skip to content

Commit 38d55fb

Browse files
committed
fix(ui-tars): resolve page down and page up event error
1 parent a5f92b8 commit 38d55fb

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

packages/shared/src/us-keyboard-layout.ts

+6-9
Original file line numberDiff line numberDiff line change
@@ -712,15 +712,12 @@ const keyMap: Record<string, KeyInput> = {
712712
};
713713

714714
export function transformHotkeyInput(keyInput: string): string[] {
715+
// page down
716+
if (keyMap[keyInput.toLowerCase()]) {
717+
return [getKeyDefinition(keyMap[keyInput.toLowerCase()])];
718+
}
719+
715720
return keyInput.split(' ').map((key) => {
716-
let newKey = key;
717-
if (keyMap[key.toLowerCase()]) {
718-
newKey = keyMap[key.toLowerCase()];
719-
}
720-
const keyDefinition = getKeyDefinition(newKey);
721-
if (keyDefinition) {
722-
return keyDefinition;
723-
}
724-
return newKey;
721+
return getKeyDefinition(keyMap[key.toLowerCase()] || key);
725722
});
726723
}

packages/shared/tests/unit-test/keyboard.test.ts

+5
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,9 @@ describe('transformHotkeyInput', () => {
5959
it('should handle empty input', () => {
6060
expect(transformHotkeyInput('')).toEqual(['']);
6161
});
62+
63+
it('should handle page down', () => {
64+
expect(transformHotkeyInput('page down')).toEqual(['PageDown']);
65+
expect(transformHotkeyInput('page up')).toEqual(['PageUp']);
66+
});
6267
});

0 commit comments

Comments
 (0)