Repository navigation
Commit a9b36ef
fix(fields): hold the filter-condition builder until the object schema answers (#35392)
Fixes #35057
Clause-②: no
Metadata-protocol: none
## 维护者速读
1.
用户能看到什么变化:管理员在共享规则里编辑已保存的筛选条件时,字段类型读回来之前,条件编辑器会短暂置灰、不接受输入;读回后照常可编辑,输入的数字按数字保存,不再存成文本。
2. 为什么做:控制台操作体验一系列卡片中的一张;之前的测试修复发现,类型读得慢时,提前输入的数字会被存成文本。
3. 出错会怎样:最坏情况是编辑器一直置灰、改不了条件(读取失败或宿主不提供字段类型时不会置灰);回滚这一个提交即可恢复。
4. 要你做什么:无,席位落地。
## What changes
`ui/packages/fields/src/widgets/FilterConditionField.tsx` (the
`filter-condition` widget behind `sys_sharing_rule.criteria_json`):
- The schema answer is keyed by the object it answers for, so a render
that names a new object never reads the previous object's field types.
- `schemaPending` = the host offers `getObjectSchema` and it has not
answered for this object yet. While it holds, the builder sits in a
`fieldset disabled` with `aria-busy`, and `handleBuilderChange` emits
nothing.
- A failed read settles to an empty field list and releases the builder.
A host with no `getObjectSchema` never holds it. Raw-JSON mode is not
held.
Route chosen: hold, not retype on arrival. Retyping would have to
survive the widget's re-seed effect, which replaces the rows whenever
what they emit differs from the stored value, so a held-then-retyped
edit would be wiped by that effect.
## The reading (os-dev-report 7002349726)
Rows `amount` 5, 6, 12, 30, 100, a `number` field, through the real
ObjectQL engine and SqlDriver. Each cell is the amounts returned.
| comparand | number | raw driver, `"6"` | engine `where`, `"6"` |
engine `filter`, `"6"` |
|:--|:--|:--|:--|:--|
| `$eq` / implicit | [6] | [6] | [6] | [6] |
| `$gt` | [12,30,100] | same | same | same |
| `$lte` | [5,6] | same | same | same |
| `$gte`+`$lte` 6..30 | [6,12,30] | same | same | same |
| `$in` [6,12] | [6,12] | same | same | same |
SQLite (better-sqlite3) and PostgreSQL 16.15 gave identical results. No
stored filter compares wrongly, and the card stays p2. The engine's
number-comparand declared-type door already narrows a numeric string to
its number before any driver. This PR removes the race at the producer.
## Tests
New pin `FilterConditionField.schemaPendingHold-35057.test.tsx` (6
cases):
- A held `getObjectSchema`, for implicit equality, `$gt` and `$lte`: the
stored row's box is disabled, and a change fired at it emits nothing.
After the answer, typing `6` emits the number (`{"amount":{"$gt":6}}`).
- CONTROL: when the schema answers first, the same number is emitted
straight away.
- Bounds of the hold: a failed read releases the builder, and a host
without `getObjectSchema` never holds it. Both of these still emit the
typed text, because no type is known.
<details><summary>Readings</summary>
All readings below were taken on the working tree that was then
committed unchanged as `53cd5c9d` (component blob `ace20001`), on base
`8b550f81`. The reverse verification ran before the commit, so its
restore was proven by hash rather than by checking out `HEAD`.
- Pin: `pnpm --dir ui exec vitest run
packages/fields/src/widgets/__tests__/FilterConditionField.schemaPendingHold-35057.test.tsx`:
Tests 6 passed.
- Reverse verification, component file swapped back to base `8b550f81`
and then restored (hash `ace20001` checked after restore): 4 failed, 2
passed. The three held cases failed with "Received element is not
disabled", and so did the failed-read release case, whose pre-answer leg
asserts the hold. The two controls passed. This is the predicted
direction.
- `pnpm --dir ui exec vitest run packages/fields/src/widgets/` on the
final tree: Test Files 147 passed (147), Tests 1437 passed (1437).
- `pnpm --filter @object-ui/fields run type-check`: 0 `error TS`.
- Derived gates (`dispatch-gates --commands`): 38 derived, 38 run, every
one exit 0. That includes `pnpm --dir ui exec vitest run scripts/` (Test
Files 171 passed, 2 skipped).
</details>
## Acceptance notes
- The app-shell `FilterConditionField` (dataset / related-list filters)
has no such window, read at source: it mounts the builder only once the
caller's typed field list is non-empty.
- A criteria already stored with a string bound is not rewritten. The
server reads it as the number it spells.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CajiB6BSQKWowy6YLB)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent 8596c80 commit a9b36ef
3 files changed
Lines changed: 196 additions & 12 deletions
File tree
- .changeset
- ui/packages/fields/src/widgets
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
679 | 679 | | |
680 | 680 | | |
681 | 681 | | |
682 | | - | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
683 | 688 | | |
684 | 689 | | |
685 | | - | |
686 | | - | |
| 690 | + | |
687 | 691 | | |
688 | 692 | | |
689 | 693 | | |
690 | 694 | | |
691 | | - | |
| 695 | + | |
692 | 696 | | |
693 | | - | |
| 697 | + | |
694 | 698 | | |
695 | 699 | | |
696 | 700 | | |
697 | 701 | | |
698 | 702 | | |
699 | | - | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
700 | 726 | | |
701 | 727 | | |
702 | 728 | | |
| |||
772 | 798 | | |
773 | 799 | | |
774 | 800 | | |
| 801 | + | |
775 | 802 | | |
776 | 803 | | |
777 | 804 | | |
| |||
838 | 865 | | |
839 | 866 | | |
840 | 867 | | |
841 | | - | |
842 | | - | |
843 | | - | |
844 | | - | |
845 | | - | |
846 | | - | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
847 | 880 | | |
848 | 881 | | |
849 | 882 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
0 commit comments