Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .changeset/10712-fields-record-query-cannot-query-reset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
'@object-ui/fields': patch
---

fix(fields): `useRecordQuery` commits nothing once it can no longer query, and a pending debounced search never runs an older query (objectui#10712)

`useRecordQuery`, the query kernel behind `LookupField`, the people picker and
`RecordPickerDialog`, cleared its records when `enabled` went false (a dialog
closing), but a read still in flight at that moment was the latest run: its
answer committed over the cleared state, and the loading state stayed on until
it landed. `reset()` had the same gap. When `objectName` or `dataSource` went
null nothing was cleared at all, so the previous object's records stayed and a
read in flight committed.

Now the reset applies whenever the hook can no longer query (`enabled` false,
or no data source or object name) and on `reset()`: it supersedes any read in
flight, so that read's answer commits nothing, ends the loading state, drops a
pending debounced search and clears the query state.

The debounced `setSearch` timer also ran the query it was armed with. A filter,
object, data-source or page-size change inside the debounce window already
re-ran the query with the typed term; the timer then ran the older query too,
and as the latest call its answer won, so the results shown were for the
previous filter. Now a pending debounced search is dropped when the query
changes. No prop, export or option changes.
36 changes: 36 additions & 0 deletions .changeset/10712-plugin-form-line-items-superseded-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
'@object-ui/plugin-form': patch
---

fix(plugin-form): the line-items panel commits only the answer to its current load, a save only to the parent it was issued for, and holds a same-parent reload while it has unsaved edits (objectui#10712)

The `record:line_items` panel (`LineItemsPanel`) loads its rows again whenever
the parent record or a load input changes. When a load was superseded by a
newer one while it was in flight (the host moved the panel to another parent,
say), its answer still landed. Landing last, it replaced the current parent's
lines (since objectui#10740 the rows it brought were refused as another
parent's, so the current lines were gone either way); landing first, it ended
the loading state and drew the grid while the current load was still pending.
Now a superseded load commits nothing: not the rows, not the end of the loading
state.

The panel's save reloaded the rows through the `load` it captured when Save was
clicked. A save that landed after the panel had moved to another parent
re-read the old parent, its lines were then committed into the new parent's
panel (and, since objectui#10740, refused there behind the placeholder), and
its failure was written over the new parent's panel. Now a save reloads only
while the parent it saved is still on screen, reading the panel's current
inputs (sort, limit, filter) rather than the ones captured at the click, and a
save whose parent has left the screen neither re-reads nor reports.

A change to a load input other than the parent (sort, limit or filter) re-read
the rows while the author had unsaved lines, and the read's commit discarded
those lines with no signal. Now, as the default record form already does for
its own background re-read, the panel holds such a change while it has unsaved
edits for the current parent: no read is issued, the edited lines stay drawn
and saveable, and the next read that runs (the post-save reload, a parent move,
or the commit of a same-parent read that was in flight) carries the change.
While a change is held, the grid shows the rows under the previous sort, filter
or limit until the panel saves, with no signal. A change while the panel is
clean, a parent move, and a change of adapter or child object still read as
before. No prop, export or schema key changes.
Loading
Loading