Skip to content

BREAKING: drop KeyborgProps (triggerKeys/dismissKeys) and dismiss timer#176

Open
layershifter wants to merge 1 commit into
microsoft:mainfrom
layershifter:perf/drop-keyborg-props
Open

BREAKING: drop KeyborgProps (triggerKeys/dismissKeys) and dismiss timer#176
layershifter wants to merge 1 commit into
microsoft:mainfrom
layershifter:perf/drop-keyborg-props

Conversation

@layershifter
Copy link
Copy Markdown
Member

@layershifter layershifter commented May 18, 2026

Summary

KeyborgProps was the only argument to createKeyborg/createKeyborgCore, gating two opt-in features:

  • triggerKeys — a custom set of key codes that should enter keyboard-navigation mode in place of the default predicate (any non-Tab key on a non-editable element). No known consumer passes a custom set; the default already covers screen-reader and Tab-driven flows.
  • dismissKeys — a key set that scheduled a 500 ms timer to dismiss keyboard mode if focus did not move (typically wired to Escape). This hand-rolled latch duplicated work consumers already do at the application level.

Drops:

  • the KeyborgProps interface,
  • the triggerKeys / dismissKeys Set construction,
  • shouldDismiss / scheduleDismiss / dismissTimer / _dismissTimeout,
  • the triggerKeys membership check in shouldTrigger,
  • the dismiss-timer cleanup branch in dispose.

onKeyDown collapses to a single guard:

const onKeyDown = (e: KeyboardEvent): void => {
  if (!isNavigating && shouldTrigger(e)) {
    setNavigating(true);
  }
};

Public API impact

  • createKeyborg(win, props?)createKeyborg(win).
  • KeyborgProps type is removed.

KeyborgProps was never re-exported from src/index.mts, so it was only reachable via deep imports. Callers passing the second argument hit a type error; callers passing nothing are unaffected. Worth a minor or major bump depending on how strict the maintainers want to be.

🤖 Generated with Claude Code

KeyborgProps was the only argument to `createKeyborg`/`createKeyborgCore`,
gating two features:

* `triggerKeys` — a custom set of keys that should opt the window into
  keyboard-navigation mode in place of "any non-Tab key on a non-editable
  element". Never used by any known consumer; the default predicate is
  already the right behaviour for screen-reader and Tab-driven flows.
* `dismissKeys` — a key set that scheduled a 500 ms timer to dismiss
  keyboard mode if focus did not move (typically wired to Escape). This
  hand-rolled latch duplicated work consumers already do at the
  application level.

Drop the props interface, the `shouldDismiss`/`scheduleDismiss`/
`dismissTimer`/`_dismissTimeout` machinery, and the `triggerKeys`
membership check in `shouldTrigger`. `onKeyDown` collapses to a single
guard: enter keyboard mode if not already in it and the key should
trigger.

`KeyborgProps` was never re-exported from `src/index.mts`, so the public
surface stays compatible aside from the (still-typed) extra `createKeyborg`
parameter going away.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
keyborg
All exports
3.974 kB
1.627 kB
3.584 kB
1.49 kB
-390 B
-137 B
keyborg
createKeyborg() & disposeKeyborg()
3.806 kB
1.586 kB
3.416 kB
1.447 kB
-390 B
-139 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
keyborg
KEYBORG_FOCUSIN constant
64 B
80 B
🤖 This report was generated against dfd7fe32327b37d8746c44aef6cebeda1ecc2397

@layershifter layershifter changed the title perf: drop KeyborgProps (triggerKeys/dismissKeys) and dismiss timer BREAKING: drop KeyborgProps (triggerKeys/dismissKeys) and dismiss timer May 18, 2026
@layershifter layershifter marked this pull request as ready for review May 18, 2026 10:34
@layershifter layershifter requested review from a team and mshoho as code owners May 18, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants