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/02 04:04:07 UTC

(causeway) 01/03: fix(webcomponents): account for sticky result header

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 a4b09ce6c1ace57064fc6a662833f70f422a0aa0
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Sep 2 05:49:58 2026 +0200

    fix(webcomponents): account for sticky result header
---
 viewers/webcomponents/foundation/src/component-styles.css  |  4 ++++
 viewers/webcomponents/foundation/src/component-styles.mjs  |  4 ++++
 .../META-INF/resources/causeway-htmx/causeway-htmx.css     |  4 ++++
 .../sample/htmx/petclinic/PetClinicHtmxPlaywrightTest.java | 14 ++++++++++----
 4 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/viewers/webcomponents/foundation/src/component-styles.css b/viewers/webcomponents/foundation/src/component-styles.css
index ccec505cfc9..b74ac3ad5b5 100644
--- a/viewers/webcomponents/foundation/src/component-styles.css
+++ b/viewers/webcomponents/foundation/src/component-styles.css
@@ -388,6 +388,10 @@ cw-action-results > .causeway-result-dismiss,
   grid-row: 1;
   justify-self: end;
 }
+cw-action-results > cw-standalone-collection .causeway-collection,
+.causeway-action-results > cw-standalone-collection .causeway-collection {
+  margin-block-start: 0;
+}
 .causeway-property {
   align-items: start;
   display: grid;
diff --git a/viewers/webcomponents/foundation/src/component-styles.mjs b/viewers/webcomponents/foundation/src/component-styles.mjs
index ccb1727bf1b..6335dc1daca 100644
--- a/viewers/webcomponents/foundation/src/component-styles.mjs
+++ b/viewers/webcomponents/foundation/src/component-styles.mjs
@@ -389,6 +389,10 @@ cw-action-results > .causeway-result-dismiss,
   grid-row: 1;
   justify-self: end;
 }
+cw-action-results > cw-standalone-collection .causeway-collection,
+.causeway-action-results > cw-standalone-collection .causeway-collection {
+  margin-block-start: 0;
+}
 .causeway-property {
   align-items: start;
   display: grid;
diff --git a/viewers/webcomponents/htmx/src/main/resources/META-INF/resources/causeway-htmx/causeway-htmx.css b/viewers/webcomponents/htmx/src/main/resources/META-INF/resources/causeway-htmx/causeway-htmx.css
index ffb9e928056..2142d85f670 100644
--- a/viewers/webcomponents/htmx/src/main/resources/META-INF/resources/causeway-htmx/causeway-htmx.css
+++ b/viewers/webcomponents/htmx/src/main/resources/META-INF/resources/causeway-htmx/causeway-htmx.css
@@ -188,6 +188,10 @@
   font-size: var(--causeway-font-size-lg);
 }
 
+cw-action-results {
+  --causeway-action-results-scroll-margin: calc(var(--causeway-nav-height) + var(--causeway-space-3));
+}
+
 cw-action-results > .causeway-result-dismiss {
   margin: 0;
 }
diff --git a/viewers/webcomponents/sample-htmx-petclinic/src/playwright/java/org/apache/causeway/viewer/webcomponents/sample/htmx/petclinic/PetClinicHtmxPlaywrightTest.java b/viewers/webcomponents/sample-htmx-petclinic/src/playwright/java/org/apache/causeway/viewer/webcomponents/sample/htmx/petclinic/PetClinicHtmxPlaywrightTest.java
index 8ac07132822..3d7383f55cb 100644
--- a/viewers/webcomponents/sample-htmx-petclinic/src/playwright/java/org/apache/causeway/viewer/webcomponents/sample/htmx/petclinic/PetClinicHtmxPlaywrightTest.java
+++ b/viewers/webcomponents/sample-htmx-petclinic/src/playwright/java/org/apache/causeway/viewer/webcomponents/sample/htmx/petclinic/PetClinicHtmxPlaywrightTest.java
@@ -514,6 +514,7 @@ void serviceActionsCoverValidationCancellationScalarAndCollections() {
         activateServiceAction("listAll");
         waitForShellResult("Pet owners", "4 results");
         assertStandaloneCollectionResult("Pet owners", 4);
+        assertResultDismissAlignment(page.locator("#causeway-result"));
         assertThat(page.locator("cw-action-results:not([hidden]) cw-standalone-collection").first().textContent())
                 .contains("Owner", "Telephone", "Email")
                 .doesNotContain("Known as", "Notes", "Unavailable");
@@ -1173,10 +1174,8 @@ void declarativeCollectionActionResultsUseDefaultAndInlineProjectionWithoutHydra
         assertThat(page.locator(liveResult).first().getAttribute("named")).isEqualTo("Pet owners");
         assertThat(page.locator(liveResult + " cw-object-link").count()).isGreaterThan(0);
         assertObjectLinkIcon(page.locator(liveResult + " cw-object-link").first());
-        page.waitForFunction("() => { const outlet = document.querySelector(\"cw-action-results[data-testid='petclinic-action-results']\"); const rect = outlet?.getBoundingClientRect(); return rect && rect.top >= 0 && rect.top < Math.min(innerHeight / 3, 160); }");
-        final var resultAlignment = (List<Number>) emptyOutlet.evaluate("element => { const dismiss = element.querySelector('[data-causeway-result-dismiss]').getBoundingClientRect(); const result = element.querySelector('cw-standalone-collection').getBoundingClientRect(); return [Math.abs(dismiss.top - result.top), dismiss.width]; }");
-        assertThat(resultAlignment.get(0).doubleValue()).isLessThan(2);
-        assertThat(resultAlignment.get(1).doubleValue()).isLessThan(160);
+        page.waitForFunction("() => { const outlet = document.querySelector(\"cw-action-results[data-testid='petclinic-action-results']\"); const header = document.querySelector('.causeway-shell-header'); const rect = outlet?.getBoundingClientRect(); const headerBottom = header?.getBoundingClientRect().bottom ?? 0; return rect && rect.top >= headerBottom + 8 && rect.top < Math.min(innerHeight / 3, 160); }");
+        assertResultDismissAlignment(emptyOutlet);
         assertThat((List<String>) page.evaluate("() => globalThis.__causewayResultPlacements"))
                 .contains("Pet owners:petclinic-action-results");
         final var defaultRequest = graphQLRequests.subList(defaultRequestStart, graphQLRequests.size()).stream()
@@ -1705,6 +1704,13 @@ private void assertStandaloneCollectionResult(final String expectedName, final i
         }
     }
 
+    @SuppressWarnings("unchecked")
+    private void assertResultDismissAlignment(final Locator outlet) {
+        final var resultAlignment = (List<Number>) outlet.evaluate("element => { const dismiss = element.querySelector('[data-causeway-result-dismiss]').getBoundingClientRect(); const result = element.querySelector('cw-standalone-collection .causeway-collection').getBoundingClientRect(); return [Math.abs(dismiss.top - result.top), dismiss.width]; }");
+        assertThat(resultAlignment.get(0).doubleValue()).isLessThan(2);
+        assertThat(resultAlignment.get(1).doubleValue()).isLessThan(160);
+    }
+
     private long graphQLOperationCount(final String operationName) {
         return graphQLRequests.stream()
                 .filter(body -> body != null && body.contains(operationName))