Keep a widget filter in its group when an update omits the group

Closed
FE
2d ago
+207-12

upsertViewWidget treats an omitted viewFilterGroupId on an existing filter as "keep the saved group", but it resolved the group's universal identifier from the input instead of from that kept value. The missing input resolved to null, and the update action handler turns universal identifiers back into ids, so the filter was silently moved out of its group even though viewFilterGroupId itself was kept.

Keeping the saved group is only right while that group survives the upsert: if the same request removes the group, the filter has to be ungrouped, or it would point at a deleted group. And the input is nullable in the schema, but an explicit null was treated like an omitted group, so a client could not ungroup a filter.

Changes

  • ViewWidgetUpsertService computes the effective viewFilterGroupId, positionInViewFilterGroup and subFieldName (input, falling back to the saved value) once, and uses them for the change check, the universal identifier resolution and the update.
  • An omitted group keeps the saved group (and position) only while that group is not among the filter groups the same upsert removes; otherwise the filter is ungrouped. The removed group ids are passed down from the filter-group operations.
  • An explicit null group ungroups the filter and clears its position. The front sends undefined for an ungrouped filter, so its behaviour is unchanged. The input DTO type is now string | null, matching the schema.

Found while reviewing #30466, which moved this code; that PR is being closed, so the fix lands on main on its own.

Testing

  • Integration upsert-view-widget (26/26):
    • "should keep a filter in its group when an update omits the group" (fails without the fix: the filter ends with viewFilterGroupId: null);
    • "should ungroup a filter whose group is removed when an update omits the group";
    • "should ungroup a filter when an update passes a null group" (fails without the fix: the filter stays in its group).

Generated by Claude Code