Skip to content

feat(input): show per-element hint in empty Placeholder field#67

Merged
zhawtof merged 2 commits into
mainfrom
claude/blissful-swanson-ec058e
May 17, 2026
Merged

feat(input): show per-element hint in empty Placeholder field#67
zhawtof merged 2 commits into
mainfrom
claude/blissful-swanson-ec058e

Conversation

@zhawtof
Copy link
Copy Markdown
Contributor

@zhawtof zhawtof commented May 17, 2026

Summary

Add an example prop to the shared PlaceholderField in input-editor.tsx so each input element type shows a per-type greyed e.g. … hint when the editor's Placeholder field is empty.

Why

When a customer drops in an input block, the factory still pre-populates placeholder.text ("Enter some text", "name@example.com", "Select a date", etc.) — keeping that default is the point of the tool, since the primary output is JSON the customer copies into their Slack app. But if the customer clears the placeholder, the editor field went blank with no affordance for what to type back.

Now: when the field is empty, an e.g. … hint appears (matching the convention every other field in the editor — Label, Action ID, Min/Max, etc. — already uses). When the field has a value (the factory default or anything the user typed), the hint is hidden and the value shows normally. No behavior change in the exported JSON.

Files touched

  • src/components/editors/input-editor.tsxPlaceholderField accepts an optional example prop, threaded through 17 call sites with element-type-appropriate examples. The plain-text editor toggles between "e.g. Enter some text" and "e.g. Enter a longer description" based on element.multiline.

History (in case the commit log is confusing)

This PR has two commits:

  1. The initial commit also stripped the factory placeholder defaults from default-blocks.ts, on the theory that the editor field and preview overlay showing the same string looked like a bug.
  2. The second commit reverts the factory changes after discussion. The factory defaults are valuable for customers who copy the JSON output, and the "duplication" was just the editor honestly reflecting the model. The PlaceholderField example-prop infrastructure from commit 1 is kept, since it's a strict UX improvement.

Net diff vs main: input-editor.tsx only.

Test plan

  • pnpm typecheck
  • pnpm lint
  • pnpm test (211/211)
  • Verified manually: dropping a fresh input block still shows the factory placeholder in both the editor field and the preview overlay (unchanged). Clearing the editor field now reveals a per-element-type e.g. … hint.

🤖 Generated with Claude Code

Every input variant factory in `default-blocks.ts` shipped with a canned
`placeholder.text` (e.g. "Enter some text", "name@example.com"). When the
user opened the Edit Input panel, that same string appeared twice on
screen at once — once as the value of the editor's Placeholder field,
and again as the placeholder overlay slack-blocks-to-jsx renders inside
the preview textarea — which read as a bug.

Drop the placeholder defaults from every input variant in both
`defaultPalette` and `legacyInputVariants`, and instead surface a
per-element-type example as the editor Input's own `placeholder=`
attribute via a new `example` prop on the shared `PlaceholderField`.
This matches how every other editor field already gives a hint
(`placeholder="e.g. Email address"`, etc.) and how Slack's own Block
Kit Builder behaves out of the box.

Section/Actions accessory placeholders are left as-is because those
editors don't expose a Placeholder field, so they can't manifest the
duplication.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown
Contributor

cloudflare-workers-and-pages Bot commented May 17, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
block-kitchen 20dd043 Commit Preview URL

Branch Preview URL
May 17 2026, 03:25 PM

Reverts the `default-blocks.ts` half of the previous commit. The
factory-supplied `placeholder.text` strings are kept after all: the
primary use of block-kitchen is producing JSON the user copies into
their Slack app, and shipping a fully-populated placeholder gives
customers a working starting point they can edit rather than an empty
field they must remember to fill in.

What the previous commit perceived as a duplication bug ("same string
in the editor field and the preview overlay at once") is just the
editor honestly reflecting the model: the form shows the current
value, the preview renders it. They're supposed to match.

Keeps the `PlaceholderField` `example` prop and per-call-site hints
from the previous commit — those now serve as the greyed `e.g. ...`
hint that appears only when the user has cleared the placeholder
value, so the editor still has a useful affordance when empty without
hiding any model state.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zhawtof zhawtof changed the title fix(input): avoid duplicating placeholder text in editor and preview feat(input): show per-element hint in empty Placeholder field May 17, 2026
@zhawtof zhawtof merged commit 4ee73ad into main May 17, 2026
12 checks passed
@zhawtof zhawtof deleted the claude/blissful-swanson-ec058e branch May 17, 2026 15:37
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.

1 participant