feat: configurable focus-on-preset-key behavior + CLAUDE.md#236
Merged
Conversation
Add a `focusOnPresetKey` init option (default `true`) gating the implicit refocus that fires in addFocusable when a component's focus key was already set as the current focus key before it mounted. Enabled by default to preserve backward compatibility. Also add a CLAUDE.md derived from CONTRIBUTING.md, docs for the new option, and a changeset. Map lodash-es -> lodash in the core jest config so the previously-unrunnable test suite executes (build still bundles lodash-es).
🦋 Changeset detectedLatest commit: 62396c0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
predikament
approved these changes
Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two changes:
1. Make the "focus on preset key" behavior configurable
When a focusable is registered via
addFocusable, if itsfocusKeyalready equals the current focus key (i.e.setFocus(key)was called before the component mounted — a "pre-set" focus key), the service immediately re-focuses it. Until now this was hardcoded.This adds a new
init()optionfocusOnPresetKey, defaulting totrueso existing behavior is unchanged. Apps that don't want this implicit refocus can opt out withinit({ focusOnPresetKey: false }).The gate lives entirely in
packages/core—useFocusable(react) and thelegacypackage (a pure re-export) inherit it automatically.2. Add
CLAUDE.mdA quick-reference guide for AI agents working in the repo, derived from
CONTRIBUTING.md(layout, commands, code style, testing, changesets, PR process).Notes
lodash-esis ESM-only and Jest can't transform it out ofnode_modules. CI only runs eslint + prettier, so this went unnoticed. Added a test-onlymoduleNameMapper(lodash-es→lodash, identical API) pluslodashas a devDependency. The rollup build still bundleslodash-esfor the published packages — runtime output is unchanged.Testing
packages/core/src/__tests__/SpatialNavigation.test.ts: default (enabled) auto-focuses a pre-set component on add;focusOnPresetKey: falsedoes not.npm run test→ 14 passed (suite now runs at all).npm run lint,npm run prettier,npm run build→ all green.Changeset
minorbump for all three packages (additive new option).🤖 Generated with Claude Code