Skip to content

feat(ui): add-question configure step; insert after the current row; scroll to and highlight the new row (#17) - #26

Open
PrjShrestha wants to merge 1 commit into
masterfrom
9d_add_question_configure
Open

PrjShrestha wants to merge 1 commit into
masterfrom
9d_add_question_configure

Conversation

@PrjShrestha

Copy link
Copy Markdown
Collaborator

Closes #17 (T9d). Parent epic #9. Plan: docs/plans/9_complex_logic_calculation_relevant_constraint/README.md (on the T9 docs branch). Independent of #23 / #24 / #25; branched from master.

What

Configure step. After a question tile (or a select's choices step), the picker shows one more step before committing: required, a hint per visible language, and a Validation slot (constraint expression with the existing "✎ build" modal, plus a constraint_message per language). 9e replaces the slot with presets. Enter anywhere commits. "add without details" is the one-click behaviour for that question; "Always skip this step" remembers it. Structural tiles, the lineage sentinel, hidden rows and edit-type reopens never get the step. The row is written with required = yes, hint::<loc>, constraint and constraint_message::<loc> only for the values the author set, so an untouched step adds exactly the row the one-click flow added.

Insert after the current row. "+ Question" lands directly after the row the author is on (the last focused card), via a new shared insertIndexAfterRow (node-tested). A begin-group row counts as "inside the group"; any other row is followed by its new sibling, so every pair stays balanced. With no current row it falls back to the existing defaultInsertIndex.

Scroll and highlight. After commit the new row is scrolled into view, focused and flashed for 2.5 s; a row that Simple mode would hide flips the editor to Full first.

The Validation slot builds against the same dependency-ordered, unique-name, non-plumbing field list the row card uses, now one function (pickableFieldsBefore), computed for the insert position.

Tests

  • surveyEdits.insertAfter.test.ts: after a top-level row, after a row inside a group, after a begin row, trailing-plumbing fallback, unknown id; each asserts structural balance of the spliced survey.
  • add-question-configure.spec.ts (Playwright): add age (integer) with required, hint, a constraint and a message while on lmp_date; it lands right after, flashed and in view; the sheet has those cells and every other row's cells are unchanged. "add without details" adds the plain row. A question added while on a row inside a group lands inside, right after it, balanced, and saves. The remembered preference commits on the tile click.

Suite note. Thirteen build specs click tiles expecting an immediate commit. Rather than rewrite forty-odd call sites, the Playwright profile seeds the "always skip" preference ON (storageState in playwright.config.ts, which also covers the specs that bypass setup.ts); the new spec clears it to drive the step. demo.spec.ts's row-order expectations now reflect insert-after-current-row (that spec already fails later on master, see below).

Validate

Check Result
pnpm typecheck clean
pnpm lint fails on master already (164 problems in untouched files); the new files lint clean, the touched legacy files add no new problems
pnpm --filter @cht-ui/shared build && test 827 pass, 0 fail (5 new)
Playwright add-question-configure, form-editing, condition-builder, pick-preexisting-values, form-data-passing, demo, geriatric-build 42 pass, 4 fail: demo 1 & 4 ("add inside", "+ Type") and geriatric-build lines 468 & 492, all four failing identically on a clean master
node scripts/corpus-sweep.mjs output byte-identical to master

🤖 Generated with Claude Code

…scroll to and highlight the new row (#17)

Clicking a type tile in the add-question picker committed immediately:
no step for required, hint or validation, and the new row was appended
after the hidden __* outputs, off-screen, with no scroll and no
highlight (UX review finding 3, P0).

QuestionTypePicker: a `configure` step between a question tile and the
commit — required, a hint per visible language, and a Validation slot
(constraint expression with the existing "✎ build" modal, plus a
constraint_message per language; 9e replaces the slot with presets).
Enter anywhere commits. "add without details" is the one-click behaviour
for this question; "Always skip this step" remembers it
(localStorage `cht-ui-builder.oneClickTiles`). Structural tiles, the
lineage sentinel, hidden rows and edit-type reopens never get the step.
A select's choices step leads into the configure step the same way.
PickerCommit gains an optional `details` block; FormEditor writes
`required = yes`, `hint::<loc>`, `constraint`, `constraint_message::<loc>`
only for the values the author set, so an untouched step adds exactly
the row the one-click flow added.

Insert position: "+ Question" lands directly after the row the author is
on (the last focused card, tracked by a focus-capture on the survey tab),
via the new shared `insertIndexAfterRow` (surveyEdits.ts, node-tested).
A begin-group row counts as "inside the group" (first child), any other
row is followed by its new sibling, so every pair stays balanced. With no
current row it falls back to `defaultInsertIndex` (before the trailing
plumbing calculates). After commit the new row is scrolled into view,
focused and flashed for 2.5 s; a row hidden in Simple mode flips the
editor to Full first.

The Validation slot's field list is the same dependency-ordered,
unique-name, non-plumbing list the row card uses (`pickableFieldsBefore`,
now one function), computed for the insert position.

Tests: surveyEdits.insertAfter.test.ts (after a top-level row, inside a
group, after a begin row, trailing-plumbing fallback, unknown id; each
asserting structural balance). Playwright add-question-configure.spec.ts:
age (integer) with required, hint, constraint and message lands right
after lmp_date, flashed and in view, with those cells on disk and every
other row's cells unchanged; "add without details"; a question added
while on a row inside a group lands inside, after it, balanced; the
remembered preference commits on the tile click.

Suite: the build specs were written against one-click tiles, so the
Playwright profile seeds the preference ON (storageState in
playwright.config.ts, which also covers specs that bypass setup.ts);
the new spec clears it. demo-1's row-order expectations now reflect
insert-after-current-row.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.

T9d: Add-question configure step; insert after current row; scroll and highlight

1 participant