Repository navigation
Show the new-key prompt as a placeholder, not a pre-filled value - #420
Merged
Merged
Conversation
The new-key input started with `translate('KEY_NEW')` as its value,
selected on focus, so confirming without typing added a key literally
called "Enter new key" (or whatever a host's custom `KEY_NEW` says). The
input now starts empty with the prompt as its placeholder, and
`commitAdd` treats an empty key as a silent no-op for both the
free-text input and the options dropdown.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Bundle size impact
|
| Format | Base raw | PR raw | Δ raw | Base gzip | PR gzip | Δ gzip |
|---|---|---|---|---|---|---|
| esm | 59.01 KB | 58.98 KB | 🟢 -32 B (-0.05%) | 20.92 KB | 20.90 KB | 🟢 -15 B (-0.07%) |
| cjs | 60.45 KB | 60.42 KB | 🟢 -32 B (-0.05%) | 20.94 KB | 20.93 KB | 🟢 -12 B (-0.06%) |
Measured from build/index.{cjs,esm}.js. Gzip at level 9.
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.
Summary
The new-key input (the text field that opens from + on an object) started with the
KEY_NEWtext as its value, selected on focus. Confirming without typing added a key literally called "Enter new key", or whatever a host's customKEY_NEWtext says (fig-tree-editor-react uses prompts such as "New variable name"). The prompt is now a placeholder: it shows the same text but can't be committed by accident.Changes
EditButtons(src/ButtonPanels.tsx): the new-key state starts empty and resets to''when the add session closes. The input takesplaceholder={translate('KEY_NEW', nodeData)}, and the select-on-focus handler is removed because there's nothing to select.commitAddreturns early on an empty key for both the free-text input and thenewKeyOptionsdropdown. Before, only the dropdown had this guard. Opening another node while an add is open still cancels the add session (EditingProvider.tsx), so the guard is only reached from ✓ and Enter.""is still a valid key, but the add input can't create one directly, because an empty field there means nothing was entered. To get one, add a key and rename it to""; rename has no empty-key check.<Select>branch is unchanged.2.0.3.Tests
setDatauncalled and the input open.ButtonPanels.tsx(the input started with a value, andsetDatawas called) and pass with this change.pnpm test(772 passed),pnpm lintandnpx tsc --noEmitare clean.pnpm format:checkflags 5 files, but they fail onmaintoo and none of them are touched here.Browser checks (Chrome, via Playwright)
I drove these with real keyboard and mouse input in two places. The first was the demo, running in
VITE_JRE_SOURCE=localmode. The second was a bare HTML page that loads the built bundle (build/index.esm.js) with no host CSS, which shows what a consumer without a CSS reset gets.'', placeholder "Enter new key", nothing selectedfresh, Enterabc, Esc, reopencustom-textexamplelibrary(level 0) andRock(level 1)'', placeholders "Name a new genre…" and "New album title…" from the example'sKEY_NEWfunctionnew-key-restrictionsexamplecontact(newKeyOptions)emailexcluded; Enter with nothing chosen is a no-op; choosingphoneadds itnew-key-restrictionsexampletags(free-text fallback)urgent+ Enter adds itfresh+ EntersetDatais only called after typing, with{ string: 'Welcome', number: 99, fresh: null }Placeholder colour: the stylesheet doesn't set one, so it comes from the host page or the browser. It's Chakra's
rgb(113, 128, 150)in the demo and Chrome's defaultrgb(117, 117, 117)on the bare page. Themes don't change it, whereas the old pre-filled prompt rendered in the theme's input text colour.Not checked: Firefox and Safari. Playwright's Firefox builds won't launch on this macOS version, so Firefox needs a manual look.
🤖 Generated with Claude Code