Skip to content

Commit fb7c380

Browse files
committed
fix(fields): the markdown editor's placeholder takes the sans stack; changeset
Claude-Session: https://claude.ai/code/session_01JQwxbX1Zhx8ST6DDF1AGvD Co-authored-by: Claude <noreply@anthropic.com>
1 parent 31e08d6 commit fb7c380

3 files changed

Lines changed: 61 additions & 1 deletion

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@object-ui/console': patch
3+
'@object-ui/fields': patch
4+
---
5+
6+
fix(console): a refused form submit marks the fields it names; the markdown editor's placeholder takes the sans stack
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
- **`@object-ui/console`**: the form page (`/f/:slug`, `/forms/:name` and `/apps/:appName/forms/:name`) used to answer every refusal with one banner and one toast and nothing on the inputs. Each refused field is now marked: `aria-invalid` on its control, and the reason under the control, which the control names in `aria-describedby`. The client required check marks each empty required field ("Name is required"). The server's field-level refusals (`400 VALIDATION_FAILED` with `fields[]`, flat or in the wrapped envelope, and `409 UNIQUE_VIOLATION` naming its `field`) mark the fields the form draws, read with `extractFieldErrors` from `@object-ui/react`, the reader the record dialog uses. A faulted `visibleWhen` marks its field and points it at the banner, which already names the field and the rule. A refusal that names no field, or only fields the form does not draw, marks nothing. On a tabbed or wizard form view the first marked field's tab or step opens. Editing a marked field clears its mark. The banner and the toast are unchanged.
12+
- **`@object-ui/fields`**: the markdown, html and richtext editor (`RichTextField`) keeps `font-mono` for the source a person types, and its placeholder now uses the sans stack (`placeholder:font-sans`), so a form's "Describe your request" no longer reads as code. This applies on every host.

‎ui/packages/fields/src/widgets/RichTextField.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,13 @@ function RichTextEditorSurface({
152152
// After the spread because it COMPOSES the host's `className` (which
153153
// reaches this component as the `className` prop) with the surface's
154154
// own classes, rather than letting the raw host value replace them.
155+
//
156+
// `font-mono` is for the SOURCE the person types; the placeholder is
157+
// prose addressed to them (a public form's "Describe your request"),
158+
// so it takes the sans stack while the typed source stays mono
159+
// (objectstack-ai/objectstack#27417).
155160
className={cn(
156-
'font-mono',
161+
'font-mono placeholder:font-sans',
157162
fullHeight ? 'text-base h-full min-h-full resize-none' : 'text-sm',
158163
className,
159164
)}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* ObjectUI
3+
* Copyright (c) 2024-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* objectstack-ai/objectstack#27417 — the markdown / html / richtext editor's
11+
* placeholder is prose, not source.
12+
*
13+
* The textarea is `font-mono` because what a person types into it is markdown
14+
* or HTML source. Its placeholder inherited the same face, so a public form's
15+
* "Describe your request" read as code. The placeholder now takes the sans
16+
* stack and the typed source keeps mono.
17+
*
18+
* jsdom computes no `::placeholder` style, so this pins the utility pair on
19+
* the control; the computed `font-family` of the placeholder was measured in
20+
* real Chromium on the console's public form page (the PR's Verification).
21+
*/
22+
23+
import { describe, it, expect } from 'vitest';
24+
import { render, screen } from '@testing-library/react';
25+
import '@testing-library/jest-dom';
26+
import type { HtmlFieldMetadata, MarkdownFieldMetadata, RichtextFieldMetadata } from '@object-ui/types';
27+
28+
import { RichTextField } from '../RichTextField';
29+
30+
const FIELDS: Array<MarkdownFieldMetadata | HtmlFieldMetadata | RichtextFieldMetadata> = [
31+
{ type: 'markdown', name: 'notes', placeholder: 'Describe your request' },
32+
{ type: 'html', name: 'body', placeholder: 'Describe your request' },
33+
{ type: 'richtext', name: 'doc', placeholder: 'Describe your request' },
34+
];
35+
36+
describe('RichTextField — the placeholder takes the sans stack, the source stays mono (#27417)', () => {
37+
it.each(FIELDS.map((f) => [f.type, f] as const))('%s', (_type, field) => {
38+
render(<RichTextField value="" onChange={() => {}} field={field} />);
39+
const box = screen.getByPlaceholderText('Describe your request');
40+
expect(box).toHaveClass('placeholder:font-sans');
41+
expect(box).toHaveClass('font-mono');
42+
});
43+
});

0 commit comments

Comments
 (0)