You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by da...@apache.org on 2026/09/01 12:33:45 UTC

(causeway) 01/07: docs(openspec): plan collection sizing and action placement

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch htmx
in repository https://gitbox.apache.org/repos/asf/causeway.git

commit 3317cb68715db2f2553421461efae218e1a1d658
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Sep 1 06:41:17 2026 +0200

    docs(openspec): plan collection sizing and action placement
---
 .../.openspec.yaml                                 |  2 +
 .../design.md                                      | 73 ++++++++++++++++++++++
 .../proposal.md                                    | 30 +++++++++
 .../specs/domain-web-components/spec.md            | 67 ++++++++++++++++++++
 .../generic-htmx-web-component-viewer/spec.md      | 24 +++++++
 .../specs/vaadin-collection-grid-adapter/spec.md   | 30 +++++++++
 .../tasks.md                                       | 25 ++++++++
 7 files changed, 251 insertions(+)

diff --git a/openspec/changes/improve-collection-sizing-and-action-placement/.openspec.yaml b/openspec/changes/improve-collection-sizing-and-action-placement/.openspec.yaml
new file mode 100644
index 00000000000..b4b3ece7847
--- /dev/null
+++ b/openspec/changes/improve-collection-sizing-and-action-placement/.openspec.yaml
@@ -0,0 +1,2 @@
+schema: spec-driven
+created: 2026-09-01
diff --git a/openspec/changes/improve-collection-sizing-and-action-placement/design.md b/openspec/changes/improve-collection-sizing-and-action-placement/design.md
new file mode 100644
index 00000000000..71bfc823a21
--- /dev/null
+++ b/openspec/changes/improve-collection-sizing-and-action-placement/design.md
@@ -0,0 +1,73 @@
+## Context
+
+The prior Grid sizing correction sets `allRowsVisible` only for explicitly bounded presentation.
+An unpaged collection with an authoritative count still qualifies as virtual Grid, so even a one-row collection retains Vaadin's default scrolling viewport.
+Petclinic does not force that height; the behavior comes from the Foundation adapter's deliberate virtual-mode setting.
+
+Direct collection-associated actions remain light-DOM `<cw-action>` children outside the owner-controlled primary rendering region.
+The member composition currently inserts the primary region before those actions and CSS lays the action row after the full collection surface.
+Effective-grid composition similarly emits the collection before its associated-action group.
+
+## Goals / Non-Goals
+
+**Goals:**
+
+- Fit a virtual Grid to its content when an authoritative total proves that the complete collection is already represented by the loaded rows.
+- Preserve the scrolling virtual viewport when more rows exist than the loaded authoritative window.
+- Place collection-associated actions before the collection surface in matching visual, DOM, and sequential keyboard order.
+- Right-align and responsively wrap the top action toolbar.
+- Preserve property-associated action placement and every existing action and collection lifecycle invariant.
+
+**Non-Goals:**
+
+- Do not disable virtual range loading for materially larger collections.
+- Do not move associated actions into Vaadin Grid, row cells, or private toolkit toolbars.
+- Do not require Petclinic-specific wrappers or CSS.
+- Do not change action declaration order, GraphQL authority, prompts, invocation, refresh, navigation, or focus restoration.
+
+## Decisions
+
+### Fit only an authoritative complete virtual window
+
+The Grid adapter will set `allRowsVisible` for bounded mode and for virtual mode only when `totalCount` is a valid authoritative count no greater than the currently projected row count.
+This uses data already frozen into the presentation and avoids guessing from viewport size, returned-row scarcity, or navigation flags.
+A later presentation with more authoritative rows or a larger total reapplies the ordinary virtual viewport.
+
+Using `totalCount <= pageSize` was rejected because the requested capacity does not prove that all rows were actually projected.
+Applying `allRowsVisible` to every virtual Grid was rejected because large collections would lose bounded viewport behavior and render excessive height.
+Adding application CSS height overrides was rejected because it would hide rather than correct the adapter mode decision.
+
+### Put collection actions before the primary region structurally
+
+For direct collection composition, the stable primary region will be maintained as the final collection child after hidden column declarations and associated actions.
+This gives visible actions both DOM and keyboard order before collection search, sorting, rows, and paging while preserving action node identity.
+The mutation observer will move only the stable primary wrapper when late parser or application children arrive; it will not recreate or reorder action nodes.
+
+For effective-grid composition, collection-associated action markup will be emitted before its collection member while property-associated actions remain after their property.
+A collection-specific association marker and shared structural CSS will right-align the action row and place the primary collection on the following full-width row.
+
+CSS visual reordering alone was rejected because keyboard traversal would continue to encounter collection controls before visually preceding actions.
+Moving actions inside owner-generated `innerHTML` was rejected because rerendering would destroy action identity and pending interaction state.
+
+### Keep actions outside the collection's visual panel
+
+The toolbar will occupy the top row immediately before the collection surface rather than being inserted into the collection heading or Vaadin Grid.
+This works for canonical, directly authored, and effective-grid collections without requiring title duplication or coupling action controls to internal collection markup.
+The toolbar remains close to the owning section heading in application layouts such as Petclinic and wraps above the collection at narrow widths.
+
+## Risks / Trade-offs
+
+- [A virtual Grid may change between compact and scrolling height after refresh] → Reapply the decision from each immutable authoritative presentation and add transition tests.
+- [Moving the stable primary wrapper could trigger mutation observation recursively] → Move it only when it is not already the last collection child and verify bounded observer behavior.
+- [Top actions could overflow beside long controls] → Give the toolbar a full responsive row, right-align at wide widths, and allow wrapping without overlap.
+- [Generated and direct compositions could drift] → Exercise both structural paths and assert equivalent DOM and keyboard order.
+
+## Migration Plan
+
+No application migration is required.
+Existing direct `<cw-action>` declarations and effective-grid associations retain their public syntax.
+Rollback consists of restoring the previous virtual-only viewport rule and post-primary collection action ordering.
+
+## Open Questions
+
+None.
\ No newline at end of file
diff --git a/openspec/changes/improve-collection-sizing-and-action-placement/proposal.md b/openspec/changes/improve-collection-sizing-and-action-placement/proposal.md
new file mode 100644
index 00000000000..9ff6f7ae9de
--- /dev/null
+++ b/openspec/changes/improve-collection-sizing-and-action-placement/proposal.md
@@ -0,0 +1,30 @@
+## Why
+
+Small unpaged collections currently retain Vaadin Grid's virtual scrolling viewport even when the authoritative total fits within the already loaded range, leaving a large blank area below a few rows.
+Collection-associated actions are also rendered after the complete collection surface, separating the controls from the collection heading and forcing unnecessary scrolling.
+
+## What Changes
+
+- Make an unpaged virtual Grid fit its rows when the authoritative collection total is small enough to fit within one requested window.
+- Retain the bounded scrolling viewport for larger virtual collections and retain current-row fitting for explicitly paged bounded collections.
+- Present collection-associated actions as an ordered responsive toolbar before the collection's primary surface rather than after the table or Grid.
+- Right-align the collection action toolbar at wide widths and allow it to wrap without overlap or overflow at narrow widths.
+- Preserve action declaration order, keyboard order, node identity, visibility, usability, prompting, invocation, refresh, and focus behavior.
+- Add Foundation and Petclinic browser coverage for compact small Grids and top-placed collection actions.
+
+## Capabilities
+
+### New Capabilities
+
+None.
+
+### Modified Capabilities
+
+- `vaadin-collection-grid-adapter`: Fit authoritative one-window virtual collections to their rows while retaining virtualization for larger totals.
+- `domain-web-components`: Place collection-associated action regions before the collection surface without changing property-associated action placement or action authority.
+- `generic-htmx-web-component-viewer`: Qualify compact Petclinic owner-pet Grid presentation and responsive top collection-action placement.
+
+## Impact
+
+The change affects Foundation Grid presentation, associated-action structural CSS, collection and Grid unit tests, component usage documentation, and Petclinic Playwright acceptance.
+It changes no public element names, GraphQL operations, domain semantics, Vaadin dependency versions, route grammar, or action lifecycle.
\ No newline at end of file
diff --git a/openspec/changes/improve-collection-sizing-and-action-placement/specs/domain-web-components/spec.md b/openspec/changes/improve-collection-sizing-and-action-placement/specs/domain-web-components/spec.md
new file mode 100644
index 00000000000..27510fbc5e6
--- /dev/null
+++ b/openspec/changes/improve-collection-sizing-and-action-placement/specs/domain-web-components/spec.md
@@ -0,0 +1,67 @@
+## MODIFIED Requirements
+
+### Requirement: Grouped object action presentation
+Object composition SHALL present actions in responsive semantic groups with consistent spacing and SHALL distinguish top-level actions from actions structurally associated with a property or collection.
+
+#### Scenario: Multiple top-level actions are rendered
+- **WHEN** an object layout allocates consecutive unassociated actions to a top-level region
+- **THEN** the generated action group wraps controls responsively with a visible consistent gap
+
+#### Scenario: Property action is rendered
+- **WHEN** an action is nested beneath a property reference in the effective grid
+- **THEN** the action is rendered in an associated-action group immediately following that property
+
+#### Scenario: Collection actions are rendered
+- **WHEN** one or more actions are nested beneath a collection reference in the effective grid
+- **THEN** the actions are rendered together in declaration order immediately before that collection's primary surface
+- **AND** they remain distinct from the top-level action group
+
+### Requirement: Stable associated-action lifecycle
+Property and collection components SHALL preserve each declared associated action as one independently connected semantic element across owner rendering and interaction state changes.
+
+#### Scenario: Property presentation changes
+- **WHEN** a property moves through loading, ready, editing, validating, failed, cancelled, and reconciled states
+- **THEN** its associated action elements retain node identity, declaration order, context generation, and pending action state
+- **AND** owner rendering does not clone, serialize, recreate, or issue requests for those actions
+
+#### Scenario: Collection presentation changes
+- **WHEN** a collection moves through inactive, loading, ready, empty, error, paging, and refreshed states
+- **THEN** its associated action elements remain connected before the collection's stable primary presentation
+- **AND** collection-column capture and row rendering neither consume nor duplicate them
+
+#### Scenario: Owner route is replaced
+- **WHEN** HTMX or another host disconnects the containing route context
+- **THEN** the owner and every associated action disconnect through the existing context lifecycle
+- **AND** cancellation and stale-result protection prevent obsolete action state from rendering after replacement
+
+#### Scenario: Owner reconnects
+- **WHEN** the same authored composition disconnects and later reconnects
+- **THEN** each action reconnects once through its ordinary semantic lifecycle
+- **AND** owner declaration capture does not create an additional live action or action request
+
+### Requirement: Accessible responsive association presentation
+Directly authored and grid-generated member associations SHALL expose equivalent ordered, keyboard-operable, responsive presentation through documented Causeway hooks and design variables.
+
+#### Scenario: Property-associated actions render at a wide viewport
+- **WHEN** one property has one or more visible associated actions
+- **THEN** the property presentation appears before its ordered action region
+- **AND** controls retain visible labels, focus indicators, and semantic button behavior
+
+#### Scenario: Collection-associated actions render at a wide viewport
+- **WHEN** one collection has one or more visible associated actions
+- **THEN** one right-aligned ordered action toolbar appears before the collection's primary surface in both visual and sequential keyboard order
+- **AND** the toolbar does not overlap the collection heading, description, search, rows, Grid, or paging controls
+
+#### Scenario: Associated actions render at a narrow viewport
+- **WHEN** the available inline size cannot contain every associated action on one row
+- **THEN** the action region wraps without horizontal page overflow, clipping, overlap, or reordered keyboard focus
+
+#### Scenario: Application styles associated actions
+- **WHEN** an application uses documented host classes, `data-causeway-associated-member`, `data-causeway-action-group`, or `--causeway-*` variables
+- **THEN** direct and generated compositions expose stable semantic styling hooks
+- **AND** application markup requires no inline styles, raw Vaadin elements, or framework-specific adapter API
+
+#### Scenario: Effective grid contains nested actions
+- **WHEN** `<cw-object>` renders property- or collection-associated actions from an effective grid
+- **THEN** generated composition remains semantically equivalent to the supported direct-child syntax
+- **AND** effective-grid parsing and action authority remain unchanged
diff --git a/openspec/changes/improve-collection-sizing-and-action-placement/specs/generic-htmx-web-component-viewer/spec.md b/openspec/changes/improve-collection-sizing-and-action-placement/specs/generic-htmx-web-component-viewer/spec.md
new file mode 100644
index 00000000000..f0a15c8a6ce
--- /dev/null
+++ b/openspec/changes/improve-collection-sizing-and-action-placement/specs/generic-htmx-web-component-viewer/spec.md
@@ -0,0 +1,24 @@
+## ADDED Requirements
+
+### Requirement: Petclinic compact collection and top-action qualification
+The Petclinic browser profile SHALL verify compact authoritative small-Grid sizing and responsive collection-associated action placement through the public HTMX viewer.
+
+#### Scenario: Owner has one companion animal
+- **WHEN** the wide owner page renders an unpaged Pets Grid whose authoritative total fits its projected rows
+- **THEN** the Grid height fits its header and data rows without a large empty scrolling viewport
+- **AND** sorting, filtering, links, columns, and collection metadata remain operable
+
+#### Scenario: Owner pet actions render
+- **WHEN** the Pets collection exposes Register a pet and Remove Pet as associated actions
+- **THEN** the actions appear in declaration order in a right-aligned toolbar before the collection surface
+- **AND** keyboard traversal reaches those actions before collection search, sort, row-link, and paging controls
+
+#### Scenario: Collection action toolbar becomes narrow
+- **WHEN** the owner page is resized below its responsive collection breakpoint
+- **THEN** the action toolbar wraps without overlap, clipping, reordered keyboard focus, or horizontal document overflow
+- **AND** native responsive collection presentation remains usable
+
+#### Scenario: Petclinic collection journey remains clean
+- **WHEN** browser acceptance operates the collection actions and collection controls
+- **THEN** prompts, cancellation, invocation, refresh, navigation, focus restoration, and authoritative GraphQL results remain unchanged
+- **AND** no console error, page error, CSP violation, external request, stale control, or overlay leak occurs
diff --git a/openspec/changes/improve-collection-sizing-and-action-placement/specs/vaadin-collection-grid-adapter/spec.md b/openspec/changes/improve-collection-sizing-and-action-placement/specs/vaadin-collection-grid-adapter/spec.md
new file mode 100644
index 00000000000..d16764f6ba3
--- /dev/null
+++ b/openspec/changes/improve-collection-sizing-and-action-placement/specs/vaadin-collection-grid-adapter/spec.md
@@ -0,0 +1,30 @@
+## MODIFIED Requirements
+
+### Requirement: Explicit paging selects bounded Grid mode
+A valid Causeway paging override SHALL select bounded Grid presentation and SHALL retain Causeway-owned previous and next controls.
+Vaadin Grid MUST NOT create an independent paging state machine.
+
+#### Scenario: Paged collection has a safe total
+- **WHEN** a qualified collection declares a valid page size and the window reports a stable total
+- **THEN** the adapter receives only the current bounded window as items
+- **AND** Causeway-owned paging controls navigate normalized server offsets
+
+#### Scenario: Bounded Grid fits its current page
+- **WHEN** the adapter renders a bounded page as Grid
+- **THEN** Grid height fits the current bounded rows without retaining its default empty viewport
+- **AND** paging controls remain outside Grid and metadata-driven
+
+#### Scenario: Complete virtual window is small
+- **WHEN** an unpaged virtual Grid has a valid authoritative total no greater than its currently projected row count
+- **THEN** Grid height fits those rows without retaining an empty scrolling viewport
+- **AND** the collection retains its virtual range contract and can requalify after refresh
+
+#### Scenario: Virtual collection exceeds its projected rows
+- **WHEN** an unpaged virtual Grid has an authoritative total greater than its currently projected row count
+- **THEN** Grid retains its bounded scrolling viewport and range provider
+- **AND** it does not expand to the complete collection or infer completeness from sparse rows
+
+#### Scenario: Unpaged collection has a safe total
+- **WHEN** a qualified collection has no page-size override and reports a stable total
+- **THEN** established virtual Grid qualification remains available
+- **AND** the existing bounded range broker remains authoritative
diff --git a/openspec/changes/improve-collection-sizing-and-action-placement/tasks.md b/openspec/changes/improve-collection-sizing-and-action-placement/tasks.md
new file mode 100644
index 00000000000..5150444efe8
--- /dev/null
+++ b/openspec/changes/improve-collection-sizing-and-action-placement/tasks.md
@@ -0,0 +1,25 @@
+## 1. Compact authoritative Grid sizing
+
+- [ ] 1.1 Fit bounded Grids and authoritative complete one-window virtual Grids to their rendered rows.
+- [ ] 1.2 Preserve scrolling virtual presentation when authoritative totals exceed projected rows and reapply sizing after presentation changes.
+- [ ] 1.3 Extend Grid widget and responsive collection tests for compact virtual, large virtual, bounded, and transition cases.
+
+## 2. Top collection-associated actions
+
+- [ ] 2.1 Maintain the stable primary wrapper after direct collection action declarations without recreating or reordering action nodes.
+- [ ] 2.2 Emit effective-grid collection action regions before their collection while preserving property action placement.
+- [ ] 2.3 Add shared responsive structural styles for a right-aligned top collection-action toolbar and wrapped narrow presentation.
+- [ ] 2.4 Extend member-composition, object-layout, and component-style tests for DOM, visual, declaration, and keyboard order.
+
+## 3. Petclinic acceptance and documentation
+
+- [ ] 3.1 Extend Petclinic Playwright coverage to verify compact one-row Pets Grid geometry.
+- [ ] 3.2 Verify collection actions precede search and row controls in visual and keyboard order at wide and narrow widths.
+- [ ] 3.3 Preserve collection action invocation, prompt cancellation, refresh, focus, diagnostics, and no-overflow behavior.
+- [ ] 3.4 Update Foundation usage documentation for compact virtual sizing and top collection-action placement.
+
+## 4. Validation
+
+- [ ] 4.1 Run complete Foundation Node and Maven suites plus relevant Vaadin Grid browser audit.
+- [ ] 4.2 Run focused Petclinic Playwright acceptance and browser diagnostics.
+- [ ] 4.3 Run IDE compilation or inspections, strict OpenSpec validation, and final diff checks.