Skip to content
Source
Sign inSign up
TanStack/hotkeys

fix(hotkeys): Don't start recording without a document, and clean up Svelte recorders in early-destroyed roots #208

MergedKevinVandymerged 1 commit intomain fromrefs/pull/208/headmerged by KevinVandy

KevinVandycommented

Follow-up to #207, fixing two valid CodeRabbit comments that came in after merge.

Changes

  • HotkeyRecorder.start() does nothing without a document. It used to add the recorder to the shared recording set regardless. Svelte's $effect teardown (from #207) and Vue's onScopeDispose never run during a server render, so a recorder started there stayed in the set and suspended hotkey dispatch for the rest of the process. The fix is in core, so it covers every adapter.
  • The Svelte recorder registers its teardown with $effect.pre. $effect is queued, so an $effect.root destroyed before effects flushed never got the teardown, and a recording started in that window kept listening and calling onRecord. $effect.pre runs as soon as it's created. createHotkeys doesn't need this, because it only registers inside an effect.

Skipped the optional Vue DOM-shim SSR nitpick: that path behaves the same as before #207.

Testing

  • New core test (node environment): start() leaves isRecording false and suspends nothing.
  • New Svelte test: a recorder started in a root destroyed before flush doesn't record.
  • Both failed before the fix. Lint, types, tests for all packages, build with size limits, and the clean-clone Intent maintainer check pass.
    1. 🦋 Changeset detected

      Latest commit: 0bcaa4ac68b0149708ae06635216109b5f6fec53

      The changes in this PR will be included in the next version bump.

      This PR includes changesets to release 18 packages
      NameType
      @tanstack/hotkeysPatch
      @tanstack/alpine-hotkeysPatch
      @tanstack/angular-hotkeysPatch
      @tanstack/ember-hotkeysPatch
      @tanstack/hotkeys-devtoolsPatch
      @tanstack/lit-hotkeysPatch
      @tanstack/octane-hotkeysPatch
      @tanstack/preact-hotkeysPatch
      @tanstack/react-hotkeysPatch
      @tanstack/solid-hotkeysPatch
      @tanstack/svelte-hotkeysPatch
      @tanstack/vue-hotkeysPatch
      @tanstack/angular-hotkeys-devtoolsPatch
      @tanstack/preact-hotkeys-devtoolsPatch
      @tanstack/react-hotkeys-devtoolsPatch
      @tanstack/solid-hotkeys-devtoolsPatch
      @tanstack/svelte-hotkeys-devtoolsPatch
      @tanstack/vue-hotkeys-devtoolsPatch

      Not sure what this means? Click here to learn what changesets are.

      Click here if you're a maintainer who wants to add another changeset to this PR

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      Caution

      Review failed

      The pull request is closed.

      Finishing Touches
      📝 Generate docstrings
      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    3. KevinVandy merged thisd43b9aa

    4. KevinVandy closed this

    5. 🚀 Changeset Version Preview

      16 package(s) bumped directly, 2 bumped as dependents.

      🟨 Minor bumps

      PackageVersionReason
      @tanstack/alpine-hotkeys0.6.0 → 0.7.0Changeset
      @tanstack/react-hotkeys0.17.0 → 0.18.0Changeset
      @tanstack/react-hotkeys-devtools0.11.1 → 0.12.0Changeset

      🟩 Patch bumps

      PackageVersionReason
      @tanstack/angular-hotkeys-devtools0.3.1 → 0.3.2Changeset
      @tanstack/ember-hotkeys0.6.0 → 0.6.1Changeset
      @tanstack/hotkeys0.18.0 → 0.18.1Changeset
      @tanstack/hotkeys-devtools1.6.0 → 1.6.1Changeset
      @tanstack/lit-hotkeys0.18.0 → 0.18.1Changeset
      @tanstack/preact-hotkeys0.17.0 → 0.17.1Changeset
      @tanstack/preact-hotkeys-devtools0.11.1 → 0.11.2Changeset
      @tanstack/solid-hotkeys0.17.0 → 0.17.1Changeset
      @tanstack/solid-hotkeys-devtools0.11.1 → 0.11.2Changeset
      @tanstack/svelte-hotkeys0.17.0 → 0.17.1Changeset
      @tanstack/svelte-hotkeys-devtools0.3.1 → 0.3.2Changeset
      @tanstack/vue-hotkeys0.17.0 → 0.17.1Changeset
      @tanstack/vue-hotkeys-devtools0.11.1 → 0.11.2Changeset
      @tanstack/angular-hotkeys0.17.0 → 0.17.1Dependent
      @tanstack/octane-hotkeys0.7.0 → 0.7.1Dependent
    6. 🎉 This PR has been released!

      Thank you for your contribution!

Sign in to join this conversation.