Repository navigation
feat(PowerSearch): the sheet presentation edits a draft that Done applies, and asks before discarding a changed one - #9895
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
/approve-spec 4b4324d |
|
AI review status for this pull request.
|
4b4324d to
ead48f6
Compare
|
/approve-spec ead48f6 |
There was a problem hiding this comment.
Requesting changes: the draft-and-Done model is clearly specified and owner-approved, but four issues need fixing first.
hasSameFiltersinPowerSearchBottomSheet.tsxre-implementsfilterSignaturefrompowerSearchSheetUtils.tswith a key-order-sensitiveJSON.stringify, so a filter whose value keys come in another order makes an unchanged draft ask "Discard changes?" and report anediton Done; compare withfilterSignatureinstead.- Done replays lists built from the draft at open, so a consumer that applies each
onChangelist loses anyfilterschange made while the sheet was open (including a read-only filter it added), although FR15 says such a change shows on the next open; rebase the replay on the latestfilters, or state that consequence in FR15 and DEC-7 with a test whoseonChangeapplies the lists. - AR6 in
PowerSearch.spec.mdstill requires the joined "Editable filters removed. {result count}" / "All filters removed. {result count}" announcements that this PR deletes; replace that clause with the count being spoken after Done. - After Clear all, or after removing the last filter, the sheet is headed "No filters applied" while the filters stay applied until Done; use a heading that describes the draft and amend FR12 to match.
Two non-blocking notes on comment wording are inline. The PowerSearch, Tokenizer and Table plugin suites pass at this head.
[Automated review]
|
|
||
| // Whether two filter lists hold the same filters in the same order: field, | ||
| // operator, value and the read-only flag. Values are plain JSON data. | ||
| function hasSameFilters( |
There was a problem hiding this comment.
This repeats filterSignature (powerSearchSheetUtils.ts), which this file already imports, but with JSON.stringify, which is key-order sensitive. A value like {value: 'open', type: 'enum'} edited away and back counts as changed: Escape asks "Discard changes?" and Done reports an edit, though FR15b says an equal draft reports nothing. Suggest:
function hasSameFilters(a, b) {
return (
a.length === b.length &&
a.every((filter, index) =>
b[index] != null && filterSignature(filter) === filterSignature(b[index]),
)
);
}| }, [onOpenChange]); | ||
| // Done: the draft's edits reach the field, in order, then the flow closes. | ||
| // An unchanged draft reports nothing. | ||
| const commitAndClose = useCallback(() => { |
There was a problem hiding this comment.
Each replayed list was built from the draft at open. For a consumer that applies every onChange list, a filters change the parent made while the sheet was open is replaced on Done, even a read-only filter it added. FR15 says such a change "shows on the next open". Either rebase the replay on the latest filters, or state this in FR15 and DEC-7 and cover it with a test whose onChange applies the lists. The test at PowerSearchBottomSheet.test.tsx:3364 uses a mock that never applies them.
| | FR9 | In the `popover` presentation, the opening-control descriptor owned by `component:Tokenizer/DEC-1` and consumed by PowerSearch MUST remain package-internal. PowerSearch MUST NOT add a public width, maximum-width, input-ref, or positioning prop for this behavior. | `component:Tokenizer/DEC-1`, `architecture:public-component-api`, and `component:PowerSearch/DEC-1` | Accepted contract; implementation pending | | ||
| | FR10 | `presentation` selects the surface. `adaptive`, the value when `presentation` is omitted, resolves to `bottom-sheet` on compact coarse-pointer screens and to `popover` otherwise, through the same shared resolution the selection controls use (`component:Selector/FR4`); with a fine pointer or on a screen that is not compact it renders exactly the `popover` presentation. `popover` is the tokenizer field with its typeahead and editor popover on every device, unchanged except as FR19 (no mount announcement) states. `bottom-sheet` is the trigger and sheet flow of FR11–FR21 on every device. That resolution answers `popover` on the server and during the hydrating render, so an `adaptive` field server-renders as, and hydrates without a mismatch as, the popover presentation's tokenizer field; on a compact coarse-pointer screen the first client render after hydration swaps it to the trigger. Focus follows the resolution rule below: before any interaction nothing in the field has focus and nothing moves, except that with `hasAutoFocus` the server markup's `autofocus` has focused the combobox input, and the swap then moves focus to the trigger within the same visit — the caller is told of neither a blur nor a new focus. The two closed fields share the field's wrapper, border, and minimum height for the size, and show the same tokens, but their row counts may differ: the popover field's editable tokens each carry a 16 px remove control the trigger's display-only tokens do not (FR11), so the trigger's tokens can wrap into fewer rows (seven filters in a 326 px field take seven rows editable and six as display-only tokens), and the popover field also carries its inline combobox input after the tokens, which may take a row of its own — the swap then changes the field's height by those rows (none on the measured story at 390 px, one token row at 414 px). A resolution change while the flow is open takes effect after it closes and focus has returned to the trigger (the focus the close reports, FR11) — the presentation hold `architecture:layer-runtime/INV14` assigns to the layer runtime; INV14 gap: the runtime does not yet provide one (its record names INV14 as ownership not yet met), so until it does the field keeps its own hold, to be replaced by the runtime's when it exists; when the new presentation is `popover`, focus then moves to the tokenizer's combobox input as the same visit — no `onBlur` and no second `onFocus` reaches the caller. A resolution change while the flow is closed takes effect at once; when focus is anywhere inside the closed field — the trigger, the combobox input, a token or its remove control, the clear control, or an interactive `endContent` — and the focused element does not survive the switch, focus moves to the other presentation's primary control (the combobox input, or the trigger) as a continuation of the same visit — no `onBlur` and no `onFocus` reaches the caller for the hand-off; when the focused element survives, or focus is outside the field, focus stays where it is. When the switch to the sheet presentation happens while the popover presentation's editor popover is open, the popover and its focused control unmount with the tokenizer field, and focus moves to the trigger. Focus never lands on the page body. | DEC-3; touch-flow evidence | Current contract; verified by focused sheet tests and real-engine touch evidence. | | ||
| | FR11 | In the sheet presentation the field's control is one trigger: a button with `aria-haspopup="dialog"` and `aria-expanded`, whose accessible name is the field label followed by the trigger's visible text — the placeholder while no filter exists, otherwise the text of the filter tokens — so the name contains what is visible and exposes the selected filters. The tokens are display-only — each is the token's static structure (`component:Token/FR2`): no remove control, no click of its own, no inner control inside the trigger button — and the tokens, the placeholder, and the empty space around them belong to the trigger: a tap on any of them opens the flow. Tokens wrap onto further lines; the trigger does not reserve a row of its own once a token exists. The trigger's tokens are the popover presentation's tokens, the same component and the same words for a value, and a `date_absolute` value reads as the sheet's date editor shows it (FR17): a date-only value as its day in `timezoneID`, else the UTC day, and a value whose operator sets `isDateOnly: false` as its date and time in `timezoneID`, else the viewer's zone. A `components[type].Token` override renders on the trigger in place of PowerSearch's token, receiving the props the popover presentation hands it — `config`, `filter`, `field`, `operator`, `maxLength`, `isDisabled` — with `onClick` and `onRemove` undefined, as the popover hands them for a read-only filter: the trigger's tokens are display-only, and the override formats its own value. `startIcon` renders in the trigger's lane. The result count and `endContent` render in the field's end lane, outside the trigger button and after it: an interactive `endContent` keeps its own tab stop, its own taps, and its own accessible name, and a tap on it does not open the flow, so a caller's control is never nested inside the component's button and the end lane's text is not part of the trigger's name. `size` sizes the trigger field and its tokens as it sizes the tokenizer field; `statusVariant` places `status.message` as the popover presentation places it; `hasAutoFocus` focuses the trigger on mount. `onFocus` fires when focus enters the field from outside and `onBlur` when it leaves the field: opening the flow moves focus into a sheet, outside the field, so `onBlur` fires, and the close that returns focus to the trigger fires `onFocus` — as the popover presentation fires them around its editor. While disabled the trigger stays focusable with `aria-disabled="true"`, never carries the native `disabled` attribute, does not open, and shows `disabledMessage` as the field does (`spec:AST-085/FR1`, `FR2`). When the component becomes disabled with the flow open, every open sheet of the flow closes and focus moves to the trigger, the destination this record names (`spec:AST-085/FR4`). | DEC-3; touch-flow evidence; `spec:AST-085`; WCAG 2.5.3 | Current contract; verified by focused sheet tests and real-engine touch evidence. | | ||
| | FR12 | Opening the flow from a field with at least one filter, or from a read-only field, shows the Filters sheet, a tall modal sheet named "Filters". Its header — a heading and, while the field is interactive and at least one filter exists, an Add filter button at the medium size whose hit area is at least 44 px tall — and its footer — Done, which applies the sheet's draft (FR15b), and, while `hasClear` is set, the field is interactive, and at least one editable filter exists, Clear all — stay fixed while only the rows between them scroll, the scroll viewport reaching the sheet's edge so its scrollbar does too, with the rows' text on the header's inset. One row per filter shows "{field label} {operator label}" (one catalog message, so a locale can reorder it) and, in bold, the value as the trigger's token shows it — the same formatter, so the same words, with the token's width budget lifted: the row never truncates a single value and never collapses a list to its "{n} items" count — with the token's summaries resolved from the catalog (`@astryx.powersearch.valueEditor.dateRange`, `itemsCount`, `filtersCount`, ICU plurals): an `integer` or `float` value reads as the token's own text (`String(value)`: `2.3456`, `1e+21`, `1e-7`, and `0` for negative zero) wherever the locale writes numbers with the token's numerals — Latin digits and a `.` decimal mark — and elsewhere with the locale's digits and decimal mark, no grouping and no rounding; a `string_list`, `enum_list`, or `entity_list` value reads as all of its items joined by the locale's narrow conjunction list (`Intl.ListFormat`, `{type: 'conjunction', style: 'narrow'}` — "Open, Closed" in English, "高、中" in Simplified Chinese and Japanese, "A, B und C" in German); a date-only `date_absolute` value reads as its day in `timezoneID`, else the UTC day, with no time, and one whose operator sets `isDateOnly: false` as its date and time in `timezoneID`, else the viewer's zone, a `date_range` as "date range", a `nested` value as "{n} filters", and a `date_relative` value as the value step's choice row reads it ("3 days ago", FR20) when a choice matches the stored value, otherwise as stored. A row's label and value are one catalog message, "{label} {value}", the same message the removal announcement of AR6 uses, with the value segment bold. A filter the field can edit is a row button that opens the value step on it, with a trailing remove action — an icon button at the medium size named "Remove {field label} filter", its hit area at least 44 px square, that removes it from the draft (FR15b) without opening the step — except that a filter whose operator takes an `empty` value (a one-tap boolean filter) is a row whose tap removes it, with the same trailing remove action, since it has no value to edit; a read-only filter, or every filter while the field is read-only, is a plain row with no remove action, as the popover gives such a token no remove control. A `nested` filter's row is a row button like any other; its step edits the group with the popover presentation's built-in nested editor (FR14). An editable filter whose field or operator the config no longer has — which the trigger still shows as a token — lists as a row button reading the field's label when the config still has the field and the raw key for whatever is gone — "{field key} {operator key}" when both are, "{field label} {operator key}" when only the operator is — that opens the step's "This filter is no longer available" state (FR14), its trailing remove action still the removal path; it is a plain row while the filter, or the field, is read-only. With no filter the body is one empty state: a heading "No filters applied", a line of guidance, and, while the field is interactive, a centered primary Add filter action that is then the sheet's only Add filter (the header shows none), so the single thing to do is the only visible action; the footer stays, with Done alone, while the draft differs from the applied filters (an emptied draft still has removals to apply), and is absent otherwise. Done closes the flow. Clear all opens a confirmation above the sheet — a dialog titled "Clear all filters?" with "Clear filters" and "Keep filters" — and only confirming removes the editable filters from the draft, recorded as `('remove', <index of the first removed filter>)` with `kept`, the read-only filters in their order, as the list (FR15b): read-only filters are the consumer's, not the person's, so Clear all leaves them in place, as the popover presentation's Clear all does (FR23); the Filters sheet stays open for further editing and focus returns to it (FR16). After the flow closes focus returns to the trigger. | DEC-3; touch-flow evidence; the read-only filter contract (`isReadOnly`, FR22); DEC-4 | Current contract; verified by focused sheet tests and real-engine touch evidence. | |
There was a problem hiding this comment.
With the draft model, this empty state now also shows for an emptied draft. The sheet then says "No filters applied" while the field behind it still has its filters and count, and they change only on Done. The new footer clause in this row even calls that state "the draft differs from the applied filters". Suggest a heading that describes the draft while it is dirty, for example "No filters", and amend this row to match.
|
|
||
| // ---- draft ---- | ||
| // One open flow edits one draft of the filter list, which starts as the | ||
| // committed filters. Every step's add, edit, removal and Clear all changes |
There was a problem hiding this comment.
Non-blocking (comment style): this sentence runs about 40 words and covers three topics. Keep only the reason: "Done replays each edit in order, so a consumer gets the calls a popover session makes." The comments above commitAndClose, requestDismiss and closeDiscardConfirmation restate the code and can go.
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| PowerSearch · Storybook | 236.0 kB (+16 B) · 21.8 kB CSS (0) | 7,173 (+144) | ✓ · ✓ · ✓ |
Package size: @astryxdesign/core 6.31 MB packed (+3.9 kB); no new dependencies.
API changes: none in this pull request
Committed API report behind this build: cli 8 rows, theme-butter 1 row, theme-chocolate 1 row, theme-gothic 1 row, theme-matcha 1 row, theme-neutral 1 row, theme-stone 1 row, theme-y2k 1 row; run pnpm api:report.
Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
ead48f6 to
2c16af8
Compare
|
/approve-spec 2c16af8 |
…lies, and asks before discarding a changed one The Filters flow holds a draft of the filter list from open: adding, editing and removing a filter, and Clear all, change the draft, and `onChange` is called when Done applies it — once per edit, in order, each with the list after that edit, the calls a popover session makes. A swipe, scrim or Escape close with an unchanged draft closes directly; with a changed one it opens the discard confirmation the Tokenizer sheet uses, Keep editing returning to the sheet and Discard changes closing with no report. Read-only filters stay protected in the draft, and Done stays in an emptied Filters sheet so the removals can be applied. The popover presentation is unchanged. The record states the draft, Done and the dismissal rule (FR15b, FR15c, DEC-7).
2c16af8 to
c88da4a
Compare
|
/approve-spec c88da4a |
There was a problem hiding this comment.
Approved. The sheet presentation's draft-and-Done model matches the owner-approved component:PowerSearch FR15b, FR15c and DEC-7 at this head, and the four issues from the previous review are fixed: the signature-based draft comparison, the replay onto the latest filters, AR6, and the "No filters" heading. Required CI has passed on this head.
Non-blocking:
- Miss: a field that turns read-only while the sheet is open still reports the draft on Done, because
commitAndClosereplays without anisInteractivecheck; consider skipping the replay then and stating it in FR15b, as the Tokenizer sheet's FR26 does for a disabled field. - The
onChangeprop JSDoc and theDraftEditJSDoc inPowerSearchBottomSheet.tsxstill describe "the list as it stood after that edit" and "how it was reported"; Done now reports the field's latest filters with each edit applied.
[Automated review]
| // consumer gets the calls a popover session makes and keeps a filter it | ||
| // added meanwhile. | ||
| const commitAndClose = useCallback(() => { | ||
| if (isDraftDirty) { |
There was a problem hiding this comment.
Non-blocking (Miss): if the field turns read-only while the flow is open, Done still replays the draft through onChange. In a probe, removing a filter, then re-rendering with isReadOnly and pressing Done reported remove. isReadOnly is documented as "Prevent adding, editing, or removing filters". Consider if (isDraftDirty && isInteractive), and say so in FR15b, as component:Tokenizer FR26 does for a disabled field.
| * The field's `onChange`. Done replays the draft's edits through it, in | ||
| * order, each with the list as it stood after that edit; nothing is | ||
| * reported before Done. |
There was a problem hiding this comment.
Non-blocking (comment accuracy): Done now replays each edit onto the field's latest filters, so a call does not carry "the list as it stood after that edit" in the draft. Suggested: "Done replays the draft's edits onto the field's latest filters, in order; nothing is reported before Done."
User need
PowerSearch's sheet presentation (
presentation="bottom-sheet", and the defaultadaptiveon compact touch screens) applied every edit the moment it happened: adding a filter, editing one, removing one, Clear all — each reachedonChangeat once, under the finger. The designer confirmed the model the Tokenizer sheet already has is the right one for the filter flow too: "Done to save, and cancel will trigger the confirm dialog." A person should be able to shape a set of filters on a phone and apply them once, or back out of them, without the field and its results churning on every tap.Problem and solution fit
The sheet presentation now holds a draft of the filter list from open:
onChange. The stacked steps (Add filter, value step, the Tokenizer's list-value sheet) work within the draft. Read-only filters stay protected in it: no remove action, Clear all keeps them (DEC-4), Done reports the kept list.filters: an add appends; an edit replaces the first filter matching the edited one by signature; a removal drops the filters it removed; each step callsonChangewith the list after it and that edit'schangeType/index. A filter the parent added while the flow was open (a read-only one above all) survives; an edit or removal whose target the parent removed meanwhile is skipped. An unchanged draft — compared byfilterSignature, so a value's key order does not matter — reports nothing and closes. Done stays in the Filters footer while an emptied draft still has removals to apply (previously the empty state had no footer), and that empty state is headed "No filters" (new catalog key) rather than "No filters applied", since the field's filters are applied until Done.SheetConfirmationfrom the Tokenizer sheet: "Discard changes?", "Your changes to the filters haven't been applied.", Discard changes then Keep editing (focused first). Keep editing returns focus to the Filters header's Add filter (else the step's panel); Discard changes closes with no report, and the next open starts from the applied filters. A dismissal of a step above the bottom sheet still just reveals the step beneath.SheetConfirmationand the dismissal-interception pattern from the Tokenizer sheet (requestDismissinhandleManageOpenChange/handleFieldsOpenChange).sheetDraft'shasSameSelection/nameSheetDraftChangeare id-set and single-change rules for Tokenizer; PowerSearch filters have no ids and report several changes, so the sheet has its ownhasSameFilters(field, operator, value, read-only flag, in order) and an ordered edit log. PowerSearch gets its own catalog keys (@astryx.powersearch.sheet.discardTitle/discardDescription/keepEditing/discardConfirm).presentation="popover"reports at once, no Done, no confirmation).onChangeon Done — the decision (DEC-7)onChange(filters, changeType, index)reports one change at a time and there is no public API change. Done replays the recorded edits in order onto the latestfilters, each call carrying the whole list after it. A consumer receives exactly the calls a popover session makes, with real change types and indexes; a controlled consumer that applies each call's list ends on the applied list, since every call carries the whole list; a filter the parent added mid-session survives, and an edit/removal whose target the parent removed is skipped (recorded in DEC-7). Checked:useTableFilteringand the composites consume only the list (neitherchangeTypenorindex), so replay and a single call are indistinguishable to them; replay keeps the contract honest for consumers that do read the type. Rejected: one call with a synthetic batch type (API change; an unknown type for consumers that switch on it); replaying only the net edits (an edit history that never happened); applying on dismissal (what the confirmation exists to prevent); showing an outsidefilterschange inside the open flow (the draft is the flow's own list; the change takes part on Done and shows on the next open); replaying the draft's own recorded lists (a parent-added filter would be replaced on Done).Consequences stated in the record: while the flow is open, a controlled parent's change to
filtersdoes not reach the open sheets (it takes part on Done and shows on the next open); the field's result count follows the applied filters, so it changes on Done, not on an edit — the "outcome + count in one message" Clear all announcement, which needed both in one commit, is unreachable and is removed with its two catalog keys (AR6 now says the changed count is spoken after Done); Clear all announces its outcome alone.Current specification
component:PowerSearch: FR12 (Done applies the draft; the empty state keeps Done while the draft has removals to apply and is headed "No filters" while the field's filters are still applied), FR13 and FR15 (edits write to the draft, recorded with thechangeType/indexDone reports; the controlled-update-following clauses are gone with the model that needed them), FR15b (draft and Done), FR15c (dismissal and the discard confirmation), FR16 (the controlled-update clauses on the edited filter are gone), FR23/DEC-4 (Clear all records a remove the sheet reports on Done), AR6 (the count after Done), DEC-3 (one sentence naming the model), DEC-7 (the decision above; deciderimdreamrunner, 2026-11-04, with the designer's confirmation), the verification map (FR15b/FR15c row), and the Public concepts paragraph.component:TokenizerFR27 is referenced for the confirmation's shape.pnpm check:knowledgealigned.Public delta and caller burden
No API change. In the sheet presentation
onChangefires on Done, once per edit in order, instead of per action; the popover presentation is unchanged. The[feat]changeset that introduces the unreleasedpresentationprop (0.7.8 canary) now describes this model; no separate entry, ascheck:changesetsand coverage accept the pending one.Design and alternatives
See DEC-7 above. The confirmation's shape and focus rules mirror the Tokenizer sheet's (one model across the two sheets a PowerSearch flow stacks).
Desktop no-regression
presentation="popover"andadaptiveon a mouse / non-compact screen render the tokenizer field and editor popover exactly as before:PowerSearch.tsxchanges only thepresentationJSDoc;PowerSearchBottomSheet.tsxis loaded only for the sheet;PowerSearch.test.tsx,PowerSearchEditPopover.test.tsx,PowerSearchFilterEditor.test.tsxand the Table filtering plugin tests pass unchanged; a new regression test asserts per-action commits in the popover presentation.Evidence
PowerSearchBottomSheet.test.tsx: 9 new tests (draft isolation + Done's ordered replay; unchanged draft reports nothing; an unchanged draft judged by signature with a value's keys reordered — no confirmation, nothing reported; Done's replay onto the latest filters with a parent-added read-only filter surviving, an edit matched by signature and a parent-removed target skipped; clean dismissal closes; dirty dismissal → confirmation with Keep editing (focus, draft intact) and Discard changes (no report, applied filters stand, next open fresh); dismissal from Add filter as the entry point; read-only protection through Clear all and Done; popover per-action regression). The existing sheet tests moved from "onChange on the action" to "nothing before Done, the same calls after Done"; the controlled-update focus-recovery group now drives removals through the sheet's own remove actions, and two tests state that outside updates leave the open draft untouched.check:repo,check:knowledge,check:changesets, changeset coverage, Prettier,git diff --check— results in the PR thread for the head.Writing rubric results
Scope
presentationJSDoc; additive, no migration).Testing
pnpm exec vitest run packages/core/src/PowerSearch packages/core/src/Tokenizer packages/core/src/internal packages/core/src/Table/plugins packages/core/src/i18n packages/cli/test/experimental-isolation.test.mjspackages/core/src/PowerSearch;pnpm check:repo;pnpm check:knowledge;pnpm check:changesets; changeset coverage;pnpm check:i18n-catalog; Prettier;git diff --checkpr-interaction) runs in CI.