chore(bidi): Fix naming of argument for getBidiKeyValue which should be code and not key

This commit is contained in:
Henrik Skupin 2025-01-10 14:20:04 +01:00
parent a2e2dfd446
commit e5d4cfb86e

View file

@ -7,18 +7,18 @@
/* eslint-disable curly */ /* eslint-disable curly */
export const getBidiKeyValue = (key: string) => { export const getBidiKeyValue = (code: string) => {
switch (key) { switch (code) {
case '\r': case '\r':
case '\n': case '\n':
key = 'Enter'; code = 'Enter';
break; break;
} }
// Measures the number of code points rather than UTF-16 code units. // Measures the number of code points rather than UTF-16 code units.
if ([...key].length === 1) { if ([...code].length === 1) {
return key; return code;
} }
switch (key) { switch (code) {
case 'Cancel': case 'Cancel':
return '\uE001'; return '\uE001';
case 'Help': case 'Help':
@ -226,6 +226,6 @@ export const getBidiKeyValue = (key: string) => {
case 'Quote': case 'Quote':
return '"'; return '"';
default: default:
throw new Error(`Unknown key: "${key}"`); throw new Error(`Unknown key: "${code}"`);
} }
}; };