🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@koglerch13
Copy link

@koglerch13 koglerch13 commented Dec 9, 2025

Description

Autocomplete in chromium can trigger a KeyboardEvent where the key property is undefined (as suggested here: https://issues.chromium.org/issues/40539270 and here: microsoft/TypeScript#59631).

In this case, (useMagicKeys/index.ts:122) throws an error:

const depsMapKey = `${key[0].toUpperCase()}${key.slice(1)}`

Additional context

Line :139 (in updateRefs) already suggests that an undefined value is actually anticipated:

const key = e.key?.toLowerCase()

Fixed existing test

While fixing this, I also noticed that the test 'should handle empty key events without errors' probably does not work as intended:

  • It does not fail the expect().not.toThrow
  • An unhandled error is registered by vitest instead

This is fixed in this PR as well.

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Dec 9, 2025
@koglerch13 koglerch13 changed the title KeyboardEvent with .key == undefined throws an error. fix(useMagicKeys): KeyboardEvent with .key == undefined throws an error. Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant