Draft: feat: add lit dapater packages#59
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0c2183d968
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| // Register the hotkey | ||
| registration = manager.register(sequence, descriptor as HotkeyCallback, { |
There was a problem hiding this comment.
Register the decorated method instead of the descriptor object
hotkeySequence currently passes descriptor to manager.register as if it were a callback, but SequenceManager later invokes registration.callback(event, context), so sequence matches will fail at runtime with a non-function callback. This should register the method function (typically descriptor.value) bound to the current element instance, otherwise @hotkeySequence is effectively broken.
Useful? React with 👍 / 👎.
| proto.disconnectedCallback = function () { | ||
| originalDisconnected.call(this) | ||
|
|
||
| if (registration.isActive) { |
There was a problem hiding this comment.
Check registration exists before reading isActive on teardown
connectedCallback can return before registration is created (for example when target resolves to null, or in environments without document), but disconnectedCallback always reads registration.isActive. In those cases teardown throws because registration is undefined, so components that intentionally skip registration crash on disconnect.
Useful? React with 👍 / 👎.
| const originalConnected = proto.connectedCallback | ||
| const originalDisconnected = proto.disconnectedCallback | ||
|
|
||
| let registration: HotkeyRegistrationHandle |
There was a problem hiding this comment.
Track hotkey registration per element instance
The registration handle is stored in decorator closure state on the prototype, so all instances of a decorated component share one mutable handle. When multiple instances mount, later mounts overwrite earlier handles; unmounting one instance can unregister another instance’s hotkey and leak the first one. Store registrations on this (or a WeakMap keyed by instance) so lifecycle cleanup is instance-safe.
Useful? React with 👍 / 👎.
0c2183d to
af261b1
Compare
🎯 Changes
Add Lit Adapter for Hotkeys
✅ Checklist
pnpm run test:pr.🚀 Release Impact