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/08/27 10:04:56 UTC
(causeway) branch htmx updated (9d106f22111 -> cb467ad5a86)
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a change to branch htmx
in repository https://gitbox.apache.org/repos/asf/causeway.git
from 9d106f22111 archives improved multiline property layout
new ba726288432 minor improvement to PetOwner example
new 0e6e081a3d6 plans field widget keyboard focus fixes
new bf38b2b7f4c fixes field widget keyboard focus
new a73fe20fe8e archives field widget keyboard focus fixes
new 321c26f6e2c plans preserved field clear focus
new 78531038e65 preserves field clear focus during validation
new 9361aad73f5 archives preserved field clear focus
new 4d3af1a5b53 docs(openspec): plan deleted void action navigation fix
new b324f9ac17b fix(webcomponents): route home after deleting current object
new cb467ad5a86 docs(openspec): archive deleted void action navigation fix
The 10 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../.openspec.yaml | 0
.../design.md | 72 +++++++++++++
.../evidence/baseline-and-boundaries.md | 24 +++++
.../evidence/implementation-and-qualification.md | 33 ++++++
.../proposal.md | 28 +++++
.../specs/domain-web-components/spec.md | 20 ++++
.../specs/vaadin-semantic-editor-families/spec.md | 36 +++++++
.../tasks.md | 28 +++++
.../.openspec.yaml | 0
.../design.md | 62 +++++++++++
.../evidence/baseline-and-boundaries.md | 21 ++++
.../evidence/implementation-and-qualification.md | 33 ++++++
.../proposal.md | 28 +++++
.../specs/domain-web-components/spec.md | 25 +++++
.../specs/vaadin-semantic-editor-families/spec.md | 41 ++++++++
.../2026-08-26-preserve-field-clear-focus/tasks.md | 27 +++++
.../.openspec.yaml | 2 +-
.../design.md | 36 +++++++
.../proposal.md | 26 +++++
.../generic-htmx-web-component-viewer/spec.md | 20 ++++
.../tasks.md | 10 ++
openspec/specs/domain-web-components/spec.md | 10 ++
.../generic-htmx-web-component-viewer/spec.md | 19 ++++
.../specs/vaadin-semantic-editor-families/spec.md | 18 +++-
.../webcomponents/foundation/src/field-widget.mjs | 81 +++++++++++++-
.../foundation/src/property-element.mjs | 36 +++++--
viewers/webcomponents/foundation/src/theme.css | 18 ++++
.../foundation/test/field-widget.test.mjs | 103 ++++++++++++++++++
.../foundation/test/fixtures/fake-vaadin-basic.mjs | 1 +
.../foundation/test/interaction.test.mjs | 117 +++++++++++++++++++++
.../resources/causeway-htmx/causeway-htmx.mjs | 23 +++-
.../sample/htmx/petclinic/domain/PetOwner.java | 5 +
.../petclinic/PetClinicHtmxPlaywrightTest.java | 44 ++++++--
33 files changed, 1021 insertions(+), 26 deletions(-)
copy openspec/changes/archive/{2026-08-26-defer-action-prompt-validation-until-focus-leave => 2026-08-26-fix-field-widget-keyboard-focus}/.openspec.yaml (100%)
create mode 100644 openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/design.md
create mode 100644 openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/evidence/baseline-and-boundaries.md
create mode 100644 openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/evidence/implementation-and-qualification.md
create mode 100644 openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/proposal.md
create mode 100644 openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/specs/domain-web-components/spec.md
create mode 100644 openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/specs/vaadin-semantic-editor-families/spec.md
create mode 100644 openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/tasks.md
copy openspec/changes/archive/{2026-08-26-defer-action-prompt-validation-until-focus-leave => 2026-08-26-preserve-field-clear-focus}/.openspec.yaml (100%)
create mode 100644 openspec/changes/archive/2026-08-26-preserve-field-clear-focus/design.md
create mode 100644 openspec/changes/archive/2026-08-26-preserve-field-clear-focus/evidence/baseline-and-boundaries.md
create mode 100644 openspec/changes/archive/2026-08-26-preserve-field-clear-focus/evidence/implementation-and-qualification.md
create mode 100644 openspec/changes/archive/2026-08-26-preserve-field-clear-focus/proposal.md
create mode 100644 openspec/changes/archive/2026-08-26-preserve-field-clear-focus/specs/domain-web-components/spec.md
create mode 100644 openspec/changes/archive/2026-08-26-preserve-field-clear-focus/specs/vaadin-semantic-editor-families/spec.md
create mode 100644 openspec/changes/archive/2026-08-26-preserve-field-clear-focus/tasks.md
copy openspec/changes/archive/{2026-08-04-reconcile-command-recording-core-policy => 2026-08-27-fix-deleted-void-action-navigation}/.openspec.yaml (50%)
create mode 100644 openspec/changes/archive/2026-08-27-fix-deleted-void-action-navigation/design.md
create mode 100644 openspec/changes/archive/2026-08-27-fix-deleted-void-action-navigation/proposal.md
create mode 100644 openspec/changes/archive/2026-08-27-fix-deleted-void-action-navigation/specs/generic-htmx-web-component-viewer/spec.md
create mode 100644 openspec/changes/archive/2026-08-27-fix-deleted-void-action-navigation/tasks.md
(causeway) 07/10: archives preserved field clear focus
Posted by da...@apache.org.
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 9361aad73f523d96e332dae0133f2afac75b2259
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Aug 26 22:39:53 2026 +0100
archives preserved field clear focus
---
.../2026-08-26-preserve-field-clear-focus}/.openspec.yaml | 0
.../2026-08-26-preserve-field-clear-focus}/design.md | 0
.../evidence/baseline-and-boundaries.md | 0
.../evidence/implementation-and-qualification.md | 0
.../2026-08-26-preserve-field-clear-focus}/proposal.md | 0
.../specs/domain-web-components/spec.md | 0
.../specs/vaadin-semantic-editor-families/spec.md | 0
.../2026-08-26-preserve-field-clear-focus}/tasks.md | 0
openspec/specs/domain-web-components/spec.md | 13 +++++++++----
openspec/specs/vaadin-semantic-editor-families/spec.md | 5 +++++
10 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/openspec/changes/preserve-field-clear-focus/.openspec.yaml b/openspec/changes/archive/2026-08-26-preserve-field-clear-focus/.openspec.yaml
similarity index 100%
rename from openspec/changes/preserve-field-clear-focus/.openspec.yaml
rename to openspec/changes/archive/2026-08-26-preserve-field-clear-focus/.openspec.yaml
diff --git a/openspec/changes/preserve-field-clear-focus/design.md b/openspec/changes/archive/2026-08-26-preserve-field-clear-focus/design.md
similarity index 100%
rename from openspec/changes/preserve-field-clear-focus/design.md
rename to openspec/changes/archive/2026-08-26-preserve-field-clear-focus/design.md
diff --git a/openspec/changes/preserve-field-clear-focus/evidence/baseline-and-boundaries.md b/openspec/changes/archive/2026-08-26-preserve-field-clear-focus/evidence/baseline-and-boundaries.md
similarity index 100%
rename from openspec/changes/preserve-field-clear-focus/evidence/baseline-and-boundaries.md
rename to openspec/changes/archive/2026-08-26-preserve-field-clear-focus/evidence/baseline-and-boundaries.md
diff --git a/openspec/changes/preserve-field-clear-focus/evidence/implementation-and-qualification.md b/openspec/changes/archive/2026-08-26-preserve-field-clear-focus/evidence/implementation-and-qualification.md
similarity index 100%
rename from openspec/changes/preserve-field-clear-focus/evidence/implementation-and-qualification.md
rename to openspec/changes/archive/2026-08-26-preserve-field-clear-focus/evidence/implementation-and-qualification.md
diff --git a/openspec/changes/preserve-field-clear-focus/proposal.md b/openspec/changes/archive/2026-08-26-preserve-field-clear-focus/proposal.md
similarity index 100%
rename from openspec/changes/preserve-field-clear-focus/proposal.md
rename to openspec/changes/archive/2026-08-26-preserve-field-clear-focus/proposal.md
diff --git a/openspec/changes/preserve-field-clear-focus/specs/domain-web-components/spec.md b/openspec/changes/archive/2026-08-26-preserve-field-clear-focus/specs/domain-web-components/spec.md
similarity index 100%
rename from openspec/changes/preserve-field-clear-focus/specs/domain-web-components/spec.md
rename to openspec/changes/archive/2026-08-26-preserve-field-clear-focus/specs/domain-web-components/spec.md
diff --git a/openspec/changes/preserve-field-clear-focus/specs/vaadin-semantic-editor-families/spec.md b/openspec/changes/archive/2026-08-26-preserve-field-clear-focus/specs/vaadin-semantic-editor-families/spec.md
similarity index 100%
rename from openspec/changes/preserve-field-clear-focus/specs/vaadin-semantic-editor-families/spec.md
rename to openspec/changes/archive/2026-08-26-preserve-field-clear-focus/specs/vaadin-semantic-editor-families/spec.md
diff --git a/openspec/changes/preserve-field-clear-focus/tasks.md b/openspec/changes/archive/2026-08-26-preserve-field-clear-focus/tasks.md
similarity index 100%
rename from openspec/changes/preserve-field-clear-focus/tasks.md
rename to openspec/changes/archive/2026-08-26-preserve-field-clear-focus/tasks.md
diff --git a/openspec/specs/domain-web-components/spec.md b/openspec/specs/domain-web-components/spec.md
index 6bfe839026d..484826d6775 100644
--- a/openspec/specs/domain-web-components/spec.md
+++ b/openspec/specs/domain-web-components/spec.md
@@ -504,10 +504,15 @@ Standard property editors and the standard action prompt SHALL expose labelled c
- **THEN** the editor associates the reason with its input and announces it accessibly
- **AND** retains the pending value for correction or cancellation
-#### Scenario: Property validation replaces focused actions
-- **WHEN** a user tabs from a changed property editor to Save or Cancel and validation-driven rendering replaces that focused action
-- **THEN** focus remains on the equivalent newly rendered action
-- **AND** subsequent Tab or Shift+Tab navigation continues from that action without restarting at the editor
+#### Scenario: Property validation replaces focused controls
+- **WHEN** a user tabs from a changed property editor to an owned Clear, Save, or Cancel control and validation-driven rendering replaces that focused control
+- **THEN** focus remains on the equivalent newly rendered control, including while an internal adapter upgrades asynchronously
+- **AND** subsequent Tab or Shift+Tab navigation continues from that control without restarting at the editor
+
+#### Scenario: Focus leaves the property during validation
+- **WHEN** focus genuinely moves beyond the property before validation rendering completes
+- **THEN** the property does not restore an obsolete internal focus intent
+- **AND** external focus remains unchanged
### Requirement: Executable vanilla-HTML interaction acceptance composition
The interaction slice SHALL extend the existing `sample-html` application as an executable acceptance fixture using the packaged web-component artifact and the real same-origin rich GraphQL endpoint.
diff --git a/openspec/specs/vaadin-semantic-editor-families/spec.md b/openspec/specs/vaadin-semantic-editor-families/spec.md
index c20dc7eb732..82809d415f7 100644
--- a/openspec/specs/vaadin-semantic-editor-families/spec.md
+++ b/openspec/specs/vaadin-semantic-editor-families/spec.md
@@ -55,6 +55,11 @@ It MUST NOT establish a second interaction or validation state machine.
- **AND** its accessible name identifies the semantic field being cleared
- **AND** keyboard or pointer activation clears through the existing Causeway pending-value path
+#### Scenario: Clear control survives owner rerendering
+- **WHEN** validation replaces a field adapter while its Causeway-owned clear suffix has focus
+- **THEN** the replacement adapter retains the clear-focus request until its visible suffix is ready
+- **AND** focus returns to that suffix without exposing toolkit lifecycle details to the application
+
#### Scenario: Keyboard user clears a field
- **WHEN** the keyboard user activates the Causeway-owned clear affordance
- **THEN** the now-empty clear affordance is removed from the tab sequence
(causeway) 09/10: fix(webcomponents): route home after deleting current object
Posted by da...@apache.org.
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 b324f9ac17b7b5f23b8c60a58357e0378cba22c2
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Thu Aug 27 11:16:48 2026 +0200
fix(webcomponents): route home after deleting current object
---
.../fix-deleted-void-action-navigation/tasks.md | 10 +++++-----
.../resources/causeway-htmx/causeway-htmx.mjs | 23 +++++++++++++++++++---
.../petclinic/PetClinicHtmxPlaywrightTest.java | 13 +++---------
3 files changed, 28 insertions(+), 18 deletions(-)
diff --git a/openspec/changes/fix-deleted-void-action-navigation/tasks.md b/openspec/changes/fix-deleted-void-action-navigation/tasks.md
index 79ce5dcaf2a..70f3dca7646 100644
--- a/openspec/changes/fix-deleted-void-action-navigation/tasks.md
+++ b/openspec/changes/fix-deleted-void-action-navigation/tasks.md
@@ -1,10 +1,10 @@
## 1. Viewer Routing
-- [ ] 1.1 Track the current void-action route refresh in the HTMX shell without affecting unrelated navigation.
-- [ ] 1.2 Redirect a matching post-action `NOT_FOUND` object state to the configured home route while preserving the successful result.
-- [ ] 1.3 Clear post-action recovery state when the target remains available or a different terminal condition occurs.
+- [x] 1.1 Track the current void-action route refresh in the HTMX shell without affecting unrelated navigation.
+- [x] 1.2 Redirect a matching post-action `NOT_FOUND` object state to the configured home route while preserving the successful result.
+- [x] 1.3 Clear post-action recovery state when the target remains available or a different terminal condition occurs.
## 2. Regression Coverage
-- [ ] 2.1 Update the Petclinic destructive Playwright journey to assert home navigation after `PetOwner#delete`.
-- [ ] 2.2 Run focused HTMX viewer and Petclinic validation checks.
+- [x] 2.1 Update the Petclinic destructive Playwright journey to assert home navigation after `PetOwner#delete`.
+- [x] 2.2 Run focused HTMX viewer and Petclinic validation checks.
diff --git a/viewers/webcomponents/htmx/src/main/resources/META-INF/resources/causeway-htmx/causeway-htmx.mjs b/viewers/webcomponents/htmx/src/main/resources/META-INF/resources/causeway-htmx/causeway-htmx.mjs
index 19e8e22bdcd..fecb6e1f40b 100644
--- a/viewers/webcomponents/htmx/src/main/resources/META-INF/resources/causeway-htmx/causeway-htmx.mjs
+++ b/viewers/webcomponents/htmx/src/main/resources/META-INF/resources/causeway-htmx/causeway-htmx.mjs
@@ -46,6 +46,7 @@ configureCausewayReferenceWidgets({
});
let activeRequest = null;
let navigationGeneration = 0;
+let pendingVoidRefreshGeneration = null;
const resolvingHomeLandings = new WeakSet();
defineCausewayWebComponents();
@@ -79,7 +80,8 @@ function activateRouteCollections() {
}
}
-async function navigate(path, {replace = false, preserveResult = false} = {}) {
+async function navigate(path, {replace = false, preserveResult = false, recoverMissingAfterVoid = false} = {}) {
+ pendingVoidRefreshGeneration = null;
const policy = globalThis.causewayHtmxPolicy;
if (typeof policy?.navigate === 'function' && await policy.navigate({path, replace}) === true) {
return;
@@ -89,6 +91,7 @@ async function navigate(path, {replace = false, preserveResult = false} = {}) {
return;
}
const generation = ++navigationGeneration;
+ pendingVoidRefreshGeneration = recoverMissingAfterVoid ? generation : null;
routeRegion.dataset.navigationGeneration = String(generation);
for (const disclosure of document.querySelectorAll('[data-causeway-menu-disclosure][aria-expanded="true"]')) {
disclosure.click();
@@ -191,7 +194,7 @@ function presentResult(detail) {
if (context) {
globalThis.setTimeout(() => navigate(
globalThis.location.pathname + globalThis.location.search,
- {replace: true, preserveResult: true}
+ {replace: true, preserveResult: true, recoverMissingAfterVoid: result?.kind === 'void'}
), 0);
}
}
@@ -297,7 +300,12 @@ document.addEventListener(OBJECT_CONTEXT_STATE_EVENT, event => {
return;
}
page.dataset.routeState = state.status;
+ const routeGeneration = Number(routeRegion?.dataset.navigationGeneration);
+ const awaitingVoidRefresh = pendingVoidRefreshGeneration === routeGeneration;
if (state.status === 'ready' || state.status === 'partial-error') {
+ if (awaitingVoidRefresh) {
+ pendingVoidRefreshGeneration = null;
+ }
const objectTitle = state.snapshot?.data?._meta?.title;
const brand = document.querySelector('.causeway-shell-brand > span:last-child')?.textContent?.trim();
if (objectTitle) {
@@ -306,7 +314,16 @@ document.addEventListener(OBJECT_CONTEXT_STATE_EVENT, event => {
globalThis.setTimeout(activateRouteCollections, 0);
announce(state.status === 'ready' ? 'Page ready' : 'Page ready with partial information');
} else if (state.status === 'terminal-error') {
- const code = state.errors?.[0]?.extensions?.classification ?? state.errors?.[0]?.extensions?.code;
+ const code = state.errors?.[0]?.extensions?.classification
+ ?? state.errors?.[0]?.extensions?.code
+ ?? state.error?.code;
+ if (awaitingVoidRefresh) {
+ pendingVoidRefreshGeneration = null;
+ if (code === 'NOT_FOUND') {
+ void navigate(basePath, {replace: true, preserveResult: true});
+ return;
+ }
+ }
page.dataset.routeState = code === 'NOT_FOUND' ? 'not-found' : code === 'ACCESS_DENIED' ? 'access-denied' : 'terminal-error';
announce(page.dataset.routeState === 'access-denied' ? 'Access denied' : 'Page unavailable');
}
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 ab6d32ff392..c651765924f 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
@@ -521,17 +521,10 @@ void disposableOwnerExercisesCreateAndEveryObjectAction() {
assertThat(graphQLMutationCount("removePet") - removePetMutations).isEqualTo(1);
objectAction("delete").click();
- page.locator("[data-testid='causeway-shell-result']").waitFor();
- assertThat(page.locator("[data-testid='causeway-shell-result']").textContent()).contains("Completed");
+ page.waitForFunction("() => location.pathname.includes('/object/petclinic.HomePage/')");
+ waitForLogicalType("petclinic.HomePage");
+ assertThat(page.locator("[data-testid='petclinic-custom-home']").isVisible()).isTrue();
assertThat(ownerRepository.findById("owner-5")).isNull();
- try {
- page.waitForFunction("() => ['not-found', 'terminal-error'].includes(document.querySelector('[data-testid=\"causeway-route-page\"]')?.dataset.routeState)");
- } catch (final com.microsoft.playwright.TimeoutError cause) {
- throw new AssertionError("Deleted object remained present; route="
- + page.locator(ROUTE_PAGE).getAttribute("data-route-state")
- + "; context=" + page.locator("#causeway-route causeway-object-context")
- .evaluate("element => element.context?.currentState ?? element.context?.state ?? null"), cause);
- }
}
private void openHome() {
(causeway) 10/10: docs(openspec): archive deleted void action navigation fix
Posted by da...@apache.org.
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 cb467ad5a8637ea3f96c6e51927df5861084eda5
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Thu Aug 27 11:18:12 2026 +0200
docs(openspec): archive deleted void action navigation fix
---
.../.openspec.yaml | 0
.../design.md | 0
.../proposal.md | 0
.../specs/generic-htmx-web-component-viewer/spec.md | 0
.../tasks.md | 0
.../specs/generic-htmx-web-component-viewer/spec.md | 19 +++++++++++++++++++
6 files changed, 19 insertions(+)
diff --git a/openspec/changes/fix-deleted-void-action-navigation/.openspec.yaml b/openspec/changes/archive/2026-08-27-fix-deleted-void-action-navigation/.openspec.yaml
similarity index 100%
rename from openspec/changes/fix-deleted-void-action-navigation/.openspec.yaml
rename to openspec/changes/archive/2026-08-27-fix-deleted-void-action-navigation/.openspec.yaml
diff --git a/openspec/changes/fix-deleted-void-action-navigation/design.md b/openspec/changes/archive/2026-08-27-fix-deleted-void-action-navigation/design.md
similarity index 100%
rename from openspec/changes/fix-deleted-void-action-navigation/design.md
rename to openspec/changes/archive/2026-08-27-fix-deleted-void-action-navigation/design.md
diff --git a/openspec/changes/fix-deleted-void-action-navigation/proposal.md b/openspec/changes/archive/2026-08-27-fix-deleted-void-action-navigation/proposal.md
similarity index 100%
rename from openspec/changes/fix-deleted-void-action-navigation/proposal.md
rename to openspec/changes/archive/2026-08-27-fix-deleted-void-action-navigation/proposal.md
diff --git a/openspec/changes/fix-deleted-void-action-navigation/specs/generic-htmx-web-component-viewer/spec.md b/openspec/changes/archive/2026-08-27-fix-deleted-void-action-navigation/specs/generic-htmx-web-component-viewer/spec.md
similarity index 100%
rename from openspec/changes/fix-deleted-void-action-navigation/specs/generic-htmx-web-component-viewer/spec.md
rename to openspec/changes/archive/2026-08-27-fix-deleted-void-action-navigation/specs/generic-htmx-web-component-viewer/spec.md
diff --git a/openspec/changes/fix-deleted-void-action-navigation/tasks.md b/openspec/changes/archive/2026-08-27-fix-deleted-void-action-navigation/tasks.md
similarity index 100%
rename from openspec/changes/fix-deleted-void-action-navigation/tasks.md
rename to openspec/changes/archive/2026-08-27-fix-deleted-void-action-navigation/tasks.md
diff --git a/openspec/specs/generic-htmx-web-component-viewer/spec.md b/openspec/specs/generic-htmx-web-component-viewer/spec.md
index d4123a57c35..c1392121e88 100644
--- a/openspec/specs/generic-htmx-web-component-viewer/spec.md
+++ b/openspec/specs/generic-htmx-web-component-viewer/spec.md
@@ -45,6 +45,25 @@ Each browser-generated and server-parsed segment MUST use the same canonical UTF
- **THEN** shell, object, asset, home, and history URLs consistently use that path
- **AND** no route assumes deployment at the origin root
+### Requirement: Void action route recovery
+The viewer SHALL refresh the current object route after a successful void action while the object remains available, and SHALL return to its configured home route when that post-action refresh establishes that the object no longer exists.
+The fallback MUST be limited to the current post-action refresh and MUST NOT convert unrelated missing-object navigation into a home redirect.
+
+#### Scenario: Void action retains its target
+- **WHEN** a successful void action completes and the current object remains available
+- **THEN** the viewer refreshes the current object route
+- **AND** presents the updated object state on the same canonical route
+
+#### Scenario: Void action deletes its target
+- **WHEN** a successful void action completes and the refreshed current object reports `NOT_FOUND`
+- **THEN** the viewer navigates to the configured home route
+- **AND** does not leave the deleted object page in a terminal or component-error state
+
+#### Scenario: Missing object is requested independently
+- **WHEN** an object route reports `NOT_FOUND` without a current successful void-action refresh
+- **THEN** the viewer retains its bounded missing-object state
+- **AND** does not redirect to the home route
+
### Requirement: Router-owned custom-page resolution
The HTMX route resolver SHALL select one trusted custom page registered for the exact public logical type before using the generic object page, and custom definitions MAY originate from a conventional private HTML resource or the compatible Java fragment-factory SPI.
(causeway) 01/10: minor improvement to PetOwner example
Posted by da...@apache.org.
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 ba7262884320608685f109385b38f62800378d69
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Aug 26 21:13:34 2026 +0100
minor improvement to PetOwner example
---
.../viewer/webcomponents/sample/htmx/petclinic/domain/PetOwner.java | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/viewers/webcomponents/sample-htmx-petclinic/src/main/java/org/apache/causeway/viewer/webcomponents/sample/htmx/petclinic/domain/PetOwner.java b/viewers/webcomponents/sample-htmx-petclinic/src/main/java/org/apache/causeway/viewer/webcomponents/sample/htmx/petclinic/domain/PetOwner.java
index aa22a8c5ccc..24dc84d3ea0 100644
--- a/viewers/webcomponents/sample-htmx-petclinic/src/main/java/org/apache/causeway/viewer/webcomponents/sample/htmx/petclinic/domain/PetOwner.java
+++ b/viewers/webcomponents/sample-htmx-petclinic/src/main/java/org/apache/causeway/viewer/webcomponents/sample/htmx/petclinic/domain/PetOwner.java
@@ -230,6 +230,11 @@ public PetOwner removePet(final Pet pet) {
return this;
}
+ @MemberSupport
+ public Pet default0RemovePet() {
+ return getPets().size() == 1 ? getPets().iterator().next() : null;
+ }
+
@Action(semantics = SemanticsOf.IDEMPOTENT)
@ActionLayout(describedAs = "Updates the owner's full name.")
public PetOwner updateName(@Parameter(maxLength = 80) final String name) {
(causeway) 03/10: fixes field widget keyboard focus
Posted by da...@apache.org.
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 bf38b2b7f4c4bc6547ee2a31c95f9c2c78103b7e
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Aug 26 21:29:05 2026 +0100
fixes field widget keyboard focus
---
.../fix-field-widget-keyboard-focus/design.md | 1 +
.../evidence/baseline-and-boundaries.md | 24 +++++++
.../evidence/implementation-and-qualification.md | 33 ++++++++++
.../fix-field-widget-keyboard-focus/tasks.md | 34 +++++-----
.../webcomponents/foundation/src/field-widget.mjs | 60 ++++++++++++++++-
.../foundation/src/property-element.mjs | 15 ++---
viewers/webcomponents/foundation/src/theme.css | 18 ++++++
.../foundation/test/field-widget.test.mjs | 75 ++++++++++++++++++++++
.../foundation/test/fixtures/fake-vaadin-basic.mjs | 1 +
.../foundation/test/interaction.test.mjs | 55 ++++++++++++++++
.../petclinic/PetClinicHtmxPlaywrightTest.java | 29 +++++++++
11 files changed, 317 insertions(+), 28 deletions(-)
diff --git a/openspec/changes/fix-field-widget-keyboard-focus/design.md b/openspec/changes/fix-field-widget-keyboard-focus/design.md
index 672bae54d60..c404080756d 100644
--- a/openspec/changes/fix-field-widget-keyboard-focus/design.md
+++ b/openspec/changes/fix-field-widget-keyboard-focus/design.md
@@ -42,6 +42,7 @@ Private-part mutation is toolkit-version fragile, while Escape conflicts with Ca
### Restore native action controls synchronously
When property rerendering observes focus on Save or Cancel, it will focus the corresponding newly inserted native button immediately after replacement.
+A busy or invalid Save control will remain focusable with `aria-disabled="true"`, while the controller suppresses activation until saving is valid; native `disabled` would make focus restoration impossible.
Editor restoration will remain deferred because lazy custom-element upgrade and selection restoration require its existing microtask path.
This removes the transient body-focus window between validation renders without trapping focus or changing user-selected external focus.
diff --git a/openspec/changes/fix-field-widget-keyboard-focus/evidence/baseline-and-boundaries.md b/openspec/changes/fix-field-widget-keyboard-focus/evidence/baseline-and-boundaries.md
new file mode 100644
index 00000000000..14872c7d57d
--- /dev/null
+++ b/openspec/changes/fix-field-widget-keyboard-focus/evidence/baseline-and-boundaries.md
@@ -0,0 +1,24 @@
+# Baseline and boundaries
+
+## Reproduced defects
+
+The supplied Notes, Email Address, and Known As screenshots show a visible Vaadin clear `×` inside each optional field.
+Vaadin's current documentation states that its built-in clear button is not keyboard-focusable and that Escape is the keyboard clearing mechanism.
+Causeway already assigns Escape to cancellation of the complete property interaction, so the visible internal clear control is pointer-only in this context.
+
+The supplied keyboard sequence reproduces a second defect.
+After Edit Known As moves focus to the field, typing schedules debounced authoritative validation.
+Tab initially moves focus to Save, but validation-driven light-DOM replacement creates a transient body-focus window before queued action restoration.
+A following Tab therefore restarts at the editor rather than continuing from Save.
+
+## Preserved boundaries
+
+- Causeway owns public elements, semantic interaction state, pending values, validation, cancellation, focus, and events.
+- GraphQL remains authoritative for property preparation, validation, mutation, visibility, and usability.
+- The solution uses Vaadin's public suffix slot and does not mutate private shadow parts.
+- Required, protected, disabled, unsupported, and native-fallback editors do not gain an inappropriate clear control.
+- Protected prior or pending values remain absent from markup, events, errors, diagnostics, and evidence.
+- Escape continues to cancel the Causeway property interaction.
+- External focus departure remains possible; no focus trap or global listener is introduced.
+- Strict CSP, exact hashes, `style-src-attr 'none'`, route-lazy delivery, same-origin packaging, and toolkit rollback remain unchanged.
+- No GraphQL operation, codec, route, dependency, lockfile, or application-authored HTML changes.
diff --git a/openspec/changes/fix-field-widget-keyboard-focus/evidence/implementation-and-qualification.md b/openspec/changes/fix-field-widget-keyboard-focus/evidence/implementation-and-qualification.md
new file mode 100644
index 00000000000..1c4e1be48c5
--- /dev/null
+++ b/openspec/changes/fix-field-widget-keyboard-focus/evidence/implementation-and-qualification.md
@@ -0,0 +1,33 @@
+# Implementation and qualification
+
+## Implementation
+
+Qualified optional non-protected field adapters now disable Vaadin's intentionally non-focusable built-in clear control and append a Causeway-owned native button through the public `suffix` slot.
+The button is explicitly tabbable, uses a bounded `Clear <label>` accessible name, retains the visible multiplication-sign affordance, and has a stable Causeway class and derived test hook.
+Required, disabled, protected, password, checkbox, select, unsupported, and explicit-native controls do not gain the suffix.
+
+Initial upgrade, wrapper value assignment, input, and change events synchronize clear visibility.
+Keyboard or pointer activation clears the Vaadin control, publishes the ordinary bubbling input path, hides the now-inapplicable button, and returns focus to the field.
+Focus movement between the field and its suffix is treated as internal widget movement and does not prematurely commit an action parameter; departure from the complete widget retains the existing commit signal.
+
+Property interaction rendering now restores Save or Cancel synchronously when the corresponding owned action had focus before markup replacement.
+Save remains keyboard-focusable while busy or invalid through `aria-disabled`, and the property click controller suppresses its activation until validation permits saving.
+Deferred lazy-editor and selection restoration remains unchanged.
+
+No private toolkit shadow part, second value state, GraphQL behavior, public element name, codec, route, dependency, CSP rule, associated action, or native fallback changed.
+
+## Qualification
+
+- Focused field-widget suite: 9 passed, zero failed.
+- Focused interaction suite: 18 passed, zero failed.
+- Complete foundation Node suite: 175 passed, zero failed.
+- HTMX route-policy Node suite: 5 passed, zero failed.
+- Petclinic Java integration suite: passed.
+- Focused real-browser editor, clear, Save, and Cancel keyboard sequence: passed.
+- Complete Petclinic Vaadin-default Playwright matrix: 4 passed, zero failed.
+- Complete Petclinic explicit-native Playwright matrix: 4 passed, zero failed.
+- Foundation RAT check: passed.
+- Petclinic RAT check: passed.
+- Ordinary reactor packaging: passed and produced a 53,891-byte Petclinic jar without `BOOT-INF`.
+- Strict OpenSpec validation: passed.
+- Git whitespace validation: passed.
diff --git a/openspec/changes/fix-field-widget-keyboard-focus/tasks.md b/openspec/changes/fix-field-widget-keyboard-focus/tasks.md
index 10076fc46bb..45f2a701be2 100644
--- a/openspec/changes/fix-field-widget-keyboard-focus/tasks.md
+++ b/openspec/changes/fix-field-widget-keyboard-focus/tasks.md
@@ -1,28 +1,28 @@
## 1. Baseline and regressions
-- [ ] 1.1 Record the non-tabbable Vaadin clear control and disappearing Save focus against unchanged authority and security boundaries.
-- [ ] 1.2 Add field-widget coverage for a labelled tabbable suffix clear button, activation, visibility, and focus return.
-- [ ] 1.3 Add property-interaction coverage for Save and Cancel focus across consecutive validation renders.
-- [ ] 1.4 Add Petclinic browser coverage for editor, clear, Save, and Cancel keyboard order and Save focus persistence.
+- [x] 1.1 Record the non-tabbable Vaadin clear control and disappearing Save focus against unchanged authority and security boundaries.
+- [x] 1.2 Add field-widget coverage for a labelled tabbable suffix clear button, activation, visibility, and focus return.
+- [x] 1.3 Add property-interaction coverage for Save and Cancel focus across consecutive validation renders.
+- [x] 1.4 Add Petclinic browser coverage for editor, clear, Save, and Cancel keyboard order and Save focus persistence.
## 2. Keyboard-operable clearing
-- [ ] 2.1 Disable the qualified field's non-tabbable internal Vaadin clear control.
-- [ ] 2.2 Add a Causeway-owned native button through the supported suffix slot with a bounded accessible name.
-- [ ] 2.3 Clear through the existing bubbling pending-value path and return focus to the field.
-- [ ] 2.4 Synchronize clear visibility for initial, programmatic, input, and change values.
-- [ ] 2.5 Exclude required, protected, disabled, and unsupported controls while preserving native fallback.
-- [ ] 2.6 Add CSP-safe semantic styling for the clear suffix.
+- [x] 2.1 Disable the qualified field's non-tabbable internal Vaadin clear control.
+- [x] 2.2 Add a Causeway-owned native button through the supported suffix slot with a bounded accessible name.
+- [x] 2.3 Clear through the existing bubbling pending-value path and return focus to the field.
+- [x] 2.4 Synchronize clear visibility for initial, programmatic, input, and change values.
+- [x] 2.5 Exclude required, protected, disabled, and unsupported controls while preserving native fallback.
+- [x] 2.6 Add CSP-safe semantic styling for the clear suffix.
## 3. Property action focus
-- [ ] 3.1 Restore focused Save or Cancel synchronously after property interaction markup replacement.
-- [ ] 3.2 Retain deferred editor and selection restoration for lazy toolkit controls.
-- [ ] 3.3 Preserve validation, cancellation, semantic events, associated actions, and external focus departure.
+- [x] 3.1 Restore focused Save or Cancel synchronously after property interaction markup replacement.
+- [x] 3.2 Retain deferred editor and selection restoration for lazy toolkit controls.
+- [x] 3.3 Preserve validation, cancellation, semantic events, associated actions, and external focus departure.
## 4. Qualification
-- [ ] 4.1 Run the complete foundation and HTMX route-policy suites.
-- [ ] 4.2 Run focused Petclinic Java integration tests.
-- [ ] 4.3 Run Petclinic Playwright under Vaadin-default and explicit-native policies.
-- [ ] 4.4 Run RAT, ordinary packaging, strict OpenSpec validation, and whitespace checks.
+- [x] 4.1 Run the complete foundation and HTMX route-policy suites.
+- [x] 4.2 Run focused Petclinic Java integration tests.
+- [x] 4.3 Run Petclinic Playwright under Vaadin-default and explicit-native policies.
+- [x] 4.4 Run RAT, ordinary packaging, strict OpenSpec validation, and whitespace checks.
diff --git a/viewers/webcomponents/foundation/src/field-widget.mjs b/viewers/webcomponents/foundation/src/field-widget.mjs
index 2d1b41235a5..e154be586d5 100644
--- a/viewers/webcomponents/foundation/src/field-widget.mjs
+++ b/viewers/webcomponents/foundation/src/field-widget.mjs
@@ -138,6 +138,7 @@ export class CausewayFieldEditorElement extends HTMLElement {
constructor() {
super();
this._control = null;
+ this._clearButton = null;
this._generation = 0;
this._focusRequested = false;
this.addEventListener('keydown', event => {
@@ -156,6 +157,7 @@ export class CausewayFieldEditorElement extends HTMLElement {
disconnectedCallback() {
this._generation += 1;
this._control = null;
+ this._clearButton = null;
}
get value() {
@@ -166,6 +168,7 @@ export class CausewayFieldEditorElement extends HTMLElement {
set value(value) {
this.dataset.value = this.dataset.sensitive === 'true' ? '' : String(value ?? '');
if (this._control && this.dataset.control !== 'checkbox') this._control.value = this.dataset.value;
+ this.#refreshClearButton();
}
get checked() {
@@ -208,12 +211,13 @@ export class CausewayFieldEditorElement extends HTMLElement {
if (!this.isConnected || generation !== this._generation) return;
const control = document.createElement(tagName);
const editorName = this.dataset.causewayEditor;
+ const testId = this.dataset.testid;
this._control = control;
control.id = `${this.id}-control`;
control.setAttribute('data-causeway-editor', editorName);
this.removeAttribute('data-causeway-editor');
- if (this.dataset.testid) {
- control.setAttribute('data-testid', this.dataset.testid);
+ if (testId) {
+ control.setAttribute('data-testid', testId);
this.removeAttribute('data-testid');
}
if (this.dataset.labelledby) control.setAttribute('aria-labelledby', this.dataset.labelledby);
@@ -221,12 +225,16 @@ export class CausewayFieldEditorElement extends HTMLElement {
control.disabled = this.hasAttribute('disabled');
control.required = this.hasAttribute('required');
control.invalid = this.dataset.invalid === 'true';
- if ('clearButtonVisible' in control) control.clearButtonVisible = !control.required && this.dataset.control !== 'password-field';
+ const supportsClearButton = 'clearButtonVisible' in control;
+ if (supportsClearButton) control.clearButtonVisible = false;
control.addEventListener('focusout', event => {
if (!control.isConnected) {
return;
}
event.stopPropagation();
+ if (control.contains(event.relatedTarget)) {
+ return;
+ }
this.dispatchEvent(new CustomEvent('causeway-editor-commit', {
bubbles: true,
composed: true,
@@ -250,12 +258,20 @@ export class CausewayFieldEditorElement extends HTMLElement {
}
if (this.dataset.control === 'password-field') control.setAttribute('autocomplete', 'new-password');
}
+ if (supportsClearButton
+ && !control.required
+ && !control.disabled
+ && this.dataset.sensitive !== 'true'
+ && !['password-field', 'checkbox', 'select'].includes(this.dataset.control)) {
+ this.#installClearButton(control, testId);
+ }
this.replaceChildren(control);
await control.updateComplete;
if (!this.isConnected || generation !== this._generation) return;
if (this.dataset.inputMode && control.inputElement) {
control.inputElement.inputMode = this.dataset.inputMode;
}
+ this.#refreshClearButton();
this.dataset.widgetState = 'ready';
if (this._focusRequested) queueMicrotask(() => control.focus());
} catch (error) {
@@ -271,6 +287,39 @@ export class CausewayFieldEditorElement extends HTMLElement {
}
}
+ #installClearButton(control, testId) {
+ const clearButton = document.createElement('button');
+ const label = boundedLabel(this.dataset.label || this.dataset.causewayEditor || 'field');
+ clearButton.setAttribute('type', 'button');
+ clearButton.setAttribute('tabindex', '0');
+ clearButton.setAttribute('slot', 'suffix');
+ clearButton.setAttribute('class', 'causeway-field-clear');
+ clearButton.setAttribute('aria-label', `Clear ${label}`);
+ clearButton.setAttribute('data-causeway-field-clear', '');
+ if (testId) clearButton.setAttribute('data-testid', `${testId}-clear`);
+ clearButton.textContent = '×';
+ clearButton.addEventListener('click', event => {
+ event.preventDefault();
+ event.stopPropagation();
+ control.value = '';
+ this.dataset.value = '';
+ this.#refreshClearButton();
+ control.dispatchEvent(new Event('input', {bubbles: true, composed: true}));
+ control.focus();
+ });
+ const refresh = () => this.#refreshClearButton();
+ control.addEventListener('input', refresh);
+ control.addEventListener('change', refresh);
+ control.appendChild(clearButton);
+ this._clearButton = clearButton;
+ }
+
+ #refreshClearButton() {
+ if (this._clearButton) {
+ this._clearButton.hidden = String(this._control?.value ?? '') === '';
+ }
+ }
+
#items() {
try {
const items = JSON.parse(this.dataset.items || '[]');
@@ -281,6 +330,11 @@ export class CausewayFieldEditorElement extends HTMLElement {
}
}
+function boundedLabel(value, maximum = 120) {
+ const label = String(value ?? '').trim() || 'field';
+ return label.length > maximum ? `${label.slice(0, maximum - 1)}…` : label;
+}
+
function focusAttribute(target, name) {
for (let current = target; current;) {
const value = current.getAttribute?.(name);
diff --git a/viewers/webcomponents/foundation/src/property-element.mjs b/viewers/webcomponents/foundation/src/property-element.mjs
index 672cd4200b1..bf9f5810447 100644
--- a/viewers/webcomponents/foundation/src/property-element.mjs
+++ b/viewers/webcomponents/foundation/src/property-element.mjs
@@ -71,7 +71,7 @@ export class CausewayPropertyElement extends CausewayContextConsumerElement {
void this.beginEdit();
} else if (action === 'cancel') {
this.cancelEdit();
- } else if (action === 'save') {
+ } else if (action === 'save' && event.target?.getAttribute?.('aria-disabled') !== 'true') {
void this.saveEdit();
}
});
@@ -603,7 +603,7 @@ export class CausewayPropertyElement extends CausewayContextConsumerElement {
<div class="causeway-property-editor">${renderedEditor.html}</div>
${errorMarkup}
<div class="causeway-property-editor-actions">
- <button type="button" data-causeway-action="save"${this.#testId('save')} ${busy || interaction.error ? 'disabled' : ''}>Save</button>
+ <button type="button" data-causeway-action="save"${this.#testId('save')} aria-disabled="${busy || Boolean(interaction.error)}">Save</button>
<button type="button" data-causeway-action="cancel"${this.#testId('cancel')} ${interaction.status === InteractionStatus.SAVING ? 'disabled' : ''}>Cancel</button>
</div>
<span class="causeway-property-interaction-status" role="status">${escapeHtml(interactionStatusLabel(interaction.status))}</span>
@@ -611,14 +611,13 @@ export class CausewayPropertyElement extends CausewayContextConsumerElement {
} finally {
this.renderingInteraction = false;
}
- const focusSelector = activeEditor
- ? '[data-causeway-editor]'
- : activeAction ? `[data-causeway-action="${activeAction}"]` : '';
- if (focusSelector) {
+ if (activeAction) {
+ this.querySelector?.(`[data-causeway-action="${activeAction}"]`)?.focus?.();
+ } else if (activeEditor) {
queueMicrotask(() => {
- const focusTarget = this.querySelector?.(focusSelector);
+ const focusTarget = this.querySelector?.('[data-causeway-editor]');
focusTarget?.focus?.();
- if (activeEditor && selectionStart !== null && typeof focusTarget?.setSelectionRange === 'function') {
+ if (selectionStart !== null && typeof focusTarget?.setSelectionRange === 'function') {
focusTarget.setSelectionRange(selectionStart, selectionEnd);
}
});
diff --git a/viewers/webcomponents/foundation/src/theme.css b/viewers/webcomponents/foundation/src/theme.css
index 5d97badc203..064d568142a 100644
--- a/viewers/webcomponents/foundation/src/theme.css
+++ b/viewers/webcomponents/foundation/src/theme.css
@@ -416,6 +416,24 @@ causeway-property:last-child .causeway-property {
width: 100%;
}
+.causeway-field-clear {
+ display: inline-grid;
+ place-items: center;
+ min-width: 2rem;
+ min-height: 2rem;
+ padding: 0.15rem;
+ border-color: transparent;
+ background: transparent;
+ color: var(--causeway-muted);
+ font-size: 1.5rem;
+ line-height: 1;
+}
+
+.causeway-field-clear:hover:not(:disabled) {
+ background: var(--causeway-surface-subtle);
+ color: var(--causeway-text);
+}
+
.causeway-property-editor-actions,
.causeway-action-prompt-actions {
display: flex;
diff --git a/viewers/webcomponents/foundation/test/field-widget.test.mjs b/viewers/webcomponents/foundation/test/field-widget.test.mjs
index f04ba419f94..821a5fc5a12 100644
--- a/viewers/webcomponents/foundation/test/field-widget.test.mjs
+++ b/viewers/webcomponents/foundation/test/field-widget.test.mjs
@@ -131,6 +131,81 @@ test('upgrades through a family-local module and ignores disconnected completion
assert.notEqual(disconnected.dataset.widgetState, 'ready');
});
+test('qualified optional fields expose a labelled keyboard clear suffix', async () => {
+ configureCausewayFieldWidgets({families: ['basic'], moduleUrls: {basic: fakeBasicModule}});
+ const editor = new CausewayFieldEditorElement();
+ editor.setAttribute('id', 'field-clear');
+ editor.setAttribute('data-family', 'basic');
+ editor.setAttribute('data-control', 'text-field');
+ editor.setAttribute('data-causeway-editor', 'knownAs');
+ editor.setAttribute('data-label', 'Known As');
+ editor.setAttribute('data-value', 'Mary');
+ editor.setAttribute('data-testid', 'known-as-editor');
+ let inputEvents = 0;
+ let commitEvents = 0;
+ editor.addEventListener('input', () => { inputEvents += 1; });
+ editor.addEventListener('causeway-editor-commit', () => { commitEvents += 1; });
+ document.body.appendChild(editor);
+ await new Promise(resolve => setTimeout(resolve, 0));
+
+ const control = editor.childNodes[0];
+ const clearButton = control.childNodes[0];
+ assert.equal(control.clearButtonVisible, false);
+ assert.equal(clearButton.localName, 'button');
+ assert.equal(clearButton.getAttribute('slot'), 'suffix');
+ assert.equal(clearButton.getAttribute('tabindex'), '0');
+ assert.equal(clearButton.getAttribute('aria-label'), 'Clear Known As');
+ assert.equal(clearButton.getAttribute('data-testid'), 'known-as-editor-clear');
+ assert.equal(clearButton.hidden, false);
+
+ const internalFocusout = new Event('focusout', {bubbles: true, composed: true});
+ internalFocusout.relatedTarget = clearButton;
+ control.dispatchEvent(internalFocusout);
+ assert.equal(commitEvents, 0);
+ const externalFocusout = new Event('focusout', {bubbles: true, composed: true});
+ externalFocusout.relatedTarget = document.createElement('button');
+ control.dispatchEvent(externalFocusout);
+ assert.equal(commitEvents, 1);
+
+ control.value = '';
+ control.dispatchEvent(new Event('change', {bubbles: true, composed: true}));
+ assert.equal(clearButton.hidden, true);
+ editor.value = 'Ada';
+ assert.equal(clearButton.hidden, false);
+
+ clearButton.focus();
+ clearButton.dispatchEvent(new Event('click', {bubbles: true, cancelable: true}));
+ assert.equal(editor.value, '');
+ assert.equal(inputEvents, 1);
+ assert.equal(clearButton.hidden, true);
+ assert.equal(document.activeElement, control);
+ document.body.removeChild(editor);
+});
+
+test('required disabled and protected fields omit the clear suffix', async () => {
+ configureCausewayFieldWidgets({families: ['basic'], moduleUrls: {basic: fakeBasicModule}});
+ for (const attributes of [
+ {control: 'text-field', required: true},
+ {control: 'text-field', disabled: true},
+ {control: 'password-field', sensitive: true}
+ ]) {
+ const editor = new CausewayFieldEditorElement();
+ editor.setAttribute('data-family', 'basic');
+ editor.setAttribute('data-control', attributes.control);
+ editor.setAttribute('data-causeway-editor', 'value');
+ editor.setAttribute('data-label', 'Value');
+ editor.setAttribute('data-value', attributes.sensitive ? '' : 'current');
+ if (attributes.required) editor.setAttribute('required', '');
+ if (attributes.disabled) editor.setAttribute('disabled', '');
+ if (attributes.sensitive) editor.setAttribute('data-sensitive', 'true');
+ document.body.appendChild(editor);
+ await new Promise(resolve => setTimeout(resolve, 0));
+ assert.equal(editor.childNodes[0].childNodes.length, 0);
+ assert.equal(editor.childNodes[0].clearButtonVisible, false);
+ document.body.removeChild(editor);
+ }
+});
+
test('fails one family closed with a bounded event', async () => {
configureCausewayFieldWidgets({families: ['basic'], moduleUrls: {
basic: new URL('./fixtures/missing-field-module.mjs', import.meta.url).href
diff --git a/viewers/webcomponents/foundation/test/fixtures/fake-vaadin-basic.mjs b/viewers/webcomponents/foundation/test/fixtures/fake-vaadin-basic.mjs
index 4d9f2ab0c45..dea8b5cfbfe 100644
--- a/viewers/webcomponents/foundation/test/fixtures/fake-vaadin-basic.mjs
+++ b/viewers/webcomponents/foundation/test/fixtures/fake-vaadin-basic.mjs
@@ -12,6 +12,7 @@ class FakeVaadinControl extends (globalThis.HTMLElement ?? class {}) {
this.value = '';
this.checked = false;
this.items = [];
+ this.clearButtonVisible = false;
this.inputElement = {inputMode: '', selectionStart: 0, selectionEnd: 0, setSelectionRange() {}};
}
}
diff --git a/viewers/webcomponents/foundation/test/interaction.test.mjs b/viewers/webcomponents/foundation/test/interaction.test.mjs
index f6595c513c6..5e350fbff57 100644
--- a/viewers/webcomponents/foundation/test/interaction.test.mjs
+++ b/viewers/webcomponents/foundation/test/interaction.test.mjs
@@ -402,6 +402,61 @@ test('editable properties support prepare, validation, cancel and authoritative
assert.equal(calls.includes('update:Cancelled'), false);
});
+test('property validation preserves Save and Cancel focus across consecutive renders', async () => {
+ for (const actionName of ['save', 'cancel']) {
+ let stateListener;
+ let resolveValidation;
+ const context = {
+ registerRequirement(requirement, listener) {
+ stateListener = listener;
+ return () => {};
+ },
+ async prepareProperty() {
+ return {status: 'success', data: {capabilities: {validate: true, inputType: scalar('String'), enumValues: []}, choices: []}, errors: []};
+ },
+ async validateProperty() {
+ return new Promise(resolve => { resolveValidation = resolve; });
+ }
+ };
+ const property = new CausewayPropertyElement();
+ property.member = 'name';
+ property.editable = true;
+ property.context = context;
+ document.body.appendChild(property);
+ stateListener({
+ status: 'ready',
+ descriptor: {id: 'name', description: '', value: {typeRef: scalar('String')}},
+ data: {hidden: false, disabled: null, get: 'Original'}, errors: [], generation: 1
+ });
+ assert.equal(await property.beginEdit(), true);
+ await Promise.resolve();
+
+ const oldAction = document.createElement('button');
+ oldAction.setAttribute('data-causeway-action', actionName);
+ property.appendChild(oldAction);
+ let replacementAction = document.createElement('button');
+ replacementAction.setAttribute('data-causeway-action', actionName);
+ property.appendChild(replacementAction);
+ property.querySelector = selector => selector === `[data-causeway-action="${actionName}"]` ? replacementAction : null;
+ oldAction.focus();
+ property.setPendingValue('Changed');
+
+ const validation = property.validatePending();
+ assert.equal(document.activeElement, replacementAction);
+ assert.match(property.innerHTML, /data-causeway-action="save"[^>]+aria-disabled="true"/);
+ assert.doesNotMatch(property.innerHTML, /data-causeway-action="save"[^>]+ disabled/);
+ const finalAction = document.createElement('button');
+ finalAction.setAttribute('data-causeway-action', actionName);
+ property.appendChild(finalAction);
+ replacementAction = finalAction;
+ resolveValidation({status: 'success', data: null, errors: []});
+ await validation;
+ assert.equal(document.activeElement, finalAction);
+ assert.match(property.innerHTML, /data-causeway-action="save"[^>]+aria-disabled="false"/);
+ document.body.removeChild(property);
+ }
+});
+
test('windowed Vaadin reference adapter requests authoritative later pages', async () => {
const moduleSource = `
if (!globalThis.customElements.get('vaadin-combo-box')) globalThis.customElements.define('vaadin-combo-box', class extends HTMLElement {});
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 eab14a8db1c..3330d73990f 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
@@ -335,6 +335,35 @@ void propertyEditingAndPromptFocusRemainDeterministic() {
assertThat(disabledName.getAttribute("data-tooltip")).isNotBlank();
assertThat(disabledName.getAttribute("tabindex")).isEqualTo("0");
+ final var knownAs = page.locator("causeway-property[member='knownAs']");
+ final var knownAsEdit = knownAs.locator("[data-causeway-action='edit']");
+ knownAsEdit.click();
+ final var knownAsEditorSelector = "causeway-property[member='knownAs'] [data-causeway-editor='knownAs']";
+ final var knownAsEditor = resolveEditor(knownAsEditorSelector);
+ assertFocused(knownAsEditorSelector);
+ final var knownAsSaveSelector = "causeway-property[member='knownAs'] [data-causeway-action='save']";
+ final var knownAsCancelSelector = "causeway-property[member='knownAs'] [data-causeway-action='cancel']";
+ if (!nativeToolkit()) {
+ final var knownAsClearSelector = "causeway-property[member='knownAs'] .causeway-field-clear";
+ knownAsEditor.press("Tab");
+ assertFocused(knownAsClearSelector);
+ page.locator(knownAsClearSelector).press("Enter");
+ assertFocused(knownAsEditorSelector);
+ fillEditor(knownAsEditor, "Keyboard focus");
+ knownAsEditor.press("Tab");
+ assertFocused(knownAsClearSelector);
+ page.locator(knownAsClearSelector).press("Tab");
+ } else {
+ fillEditor(knownAsEditor, "Keyboard focus");
+ knownAsEditor.press("Tab");
+ }
+ assertFocused(knownAsSaveSelector);
+ page.waitForTimeout(750);
+ assertFocused(knownAsSaveSelector);
+ page.locator(knownAsSaveSelector).press("Tab");
+ assertFocused(knownAsCancelSelector);
+ page.locator(knownAsCancelSelector).click();
+
final var notes = page.locator("causeway-property[member='notes']");
final var notesEdit = notes.locator("[data-causeway-action='edit']");
revealContainingTab(notes, notesEdit);
(causeway) 02/10: plans field widget keyboard focus fixes
Posted by da...@apache.org.
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 0e6e081a3d6b646bf1d4a3a58c1dd876e3334780
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Aug 26 21:15:58 2026 +0100
plans field widget keyboard focus fixes
---
.../fix-field-widget-keyboard-focus/.openspec.yaml | 2 +
.../fix-field-widget-keyboard-focus/design.md | 71 ++++++++++++++++++++++
.../fix-field-widget-keyboard-focus/proposal.md | 28 +++++++++
.../specs/domain-web-components/spec.md | 20 ++++++
.../specs/vaadin-semantic-editor-families/spec.md | 36 +++++++++++
.../fix-field-widget-keyboard-focus/tasks.md | 28 +++++++++
6 files changed, 185 insertions(+)
diff --git a/openspec/changes/fix-field-widget-keyboard-focus/.openspec.yaml b/openspec/changes/fix-field-widget-keyboard-focus/.openspec.yaml
new file mode 100644
index 00000000000..701445b8918
--- /dev/null
+++ b/openspec/changes/fix-field-widget-keyboard-focus/.openspec.yaml
@@ -0,0 +1,2 @@
+schema: spec-driven
+created: 2026-08-26
diff --git a/openspec/changes/fix-field-widget-keyboard-focus/design.md b/openspec/changes/fix-field-widget-keyboard-focus/design.md
new file mode 100644
index 00000000000..672bae54d60
--- /dev/null
+++ b/openspec/changes/fix-field-widget-keyboard-focus/design.md
@@ -0,0 +1,71 @@
+## Context
+
+Vaadin documents that its built-in clear button is intentionally not keyboard-focusable and that Escape performs clearing while the field owns focus.
+The Causeway field wrapper already reserves Escape for cancelling property editing, so retaining the internal clear button leaves the visible `×` pointer-only.
+Vaadin text fields and text areas support public suffix slots, allowing Causeway to supply a normal native button without reaching into toolkit shadow internals.
+
+The property controller replaces its light-DOM interaction markup when debounced validation starts and finishes.
+It currently queues restoration for both editors and actions.
+A fast second render can occur while the replacement Save control has not yet received queued focus, leaving the document body active and losing the intended tab position.
+
+## Goals / Non-Goals
+
+**Goals:**
+
+- Make every visible clear affordance supplied by qualified field adapters reachable and activatable through normal keyboard navigation.
+- Give the clear affordance a bounded accessible name and keep clearing within existing pending-value semantics.
+- Preserve the editor, clear, Save, and Cancel tab order.
+- Keep Save or Cancel focused across validation-driven markup replacement.
+- Preserve strict CSP, native fallback, protected values, and GraphQL authority.
+
+**Non-Goals:**
+
+- Change Vaadin's internal shadow-DOM clear button implementation.
+- Add a clear affordance to required, protected, checkbox, or selection controls that do not currently qualify for one.
+- Change Escape cancellation, property validation timing, action-prompt behavior, or reference autocomplete controls.
+- Expose raw Vaadin APIs to application markup.
+
+## Decisions
+
+### Use a Causeway-owned native suffix button
+
+For an optional non-protected Vaadin field that supports the public clear-button capability, the adapter will disable the non-tabbable built-in control and append a native button in Vaadin's public `suffix` slot.
+The button will have a Causeway class, `type="button"`, and an accessible name derived from the bounded semantic label.
+It will be shown only while the field has a value.
+
+Activation will clear the internal control, emit the same bubbling input path used by ordinary editing, and return focus to the field after the now-empty suffix is hidden.
+This keeps the owning property or action interaction authoritative and avoids a second value state machine.
+
+Alternatives were to mutate a private shadow part or merely document Escape.
+Private-part mutation is toolkit-version fragile, while Escape conflicts with Causeway's established cancellation contract and does not make the visible control reachable.
+
+### Restore native action controls synchronously
+
+When property rerendering observes focus on Save or Cancel, it will focus the corresponding newly inserted native button immediately after replacement.
+Editor restoration will remain deferred because lazy custom-element upgrade and selection restoration require its existing microtask path.
+
+This removes the transient body-focus window between validation renders without trapping focus or changing user-selected external focus.
+
+### Keep styling semantic and CSP-safe
+
+The standard theme will style only the Causeway-owned clear suffix class.
+No inline style, shadow-root mutation, extra asset, CSP exception, or Vaadin theme API is required.
+
+### Qualify lifecycle and browser tab order
+
+Foundation tests will verify suffix semantics, keyboard activation, pending-value events, value-dependent visibility, and synchronous action focus restoration across consecutive renders.
+Petclinic Playwright will verify the real Vaadin editor-to-clear-to-Save-to-Cancel sequence and Save persistence after debounced validation.
+The native policy remains covered to prove the change does not weaken rollback behavior.
+
+## Risks / Trade-offs
+
+- **Risk:** Slotted button styling could conflict with toolkit styling.
+ **Mitigation:** Use a narrowly scoped Causeway class and verify the packaged pinned toolkit in browser qualification.
+- **Risk:** Hiding the clear button after activation could strand focus.
+ **Mitigation:** Move focus back to the internal field synchronously after clearing.
+- **Risk:** Programmatic value updates could leave clear visibility stale.
+ **Mitigation:** Refresh visibility on initial upgrade, wrapper value assignment, and internal input/change paths.
+- **Risk:** Immediate action restoration could steal focus after intentional departure.
+ **Mitigation:** Restore only when the active element captured immediately before replacement was an owned Save or Cancel control.
+- **Risk:** Unrelated local PetOwner work could enter workflow commits.
+ **Mitigation:** Keep that file untouched and stage only explicit change files.
diff --git a/openspec/changes/fix-field-widget-keyboard-focus/proposal.md b/openspec/changes/fix-field-widget-keyboard-focus/proposal.md
new file mode 100644
index 00000000000..4bfb973728f
--- /dev/null
+++ b/openspec/changes/fix-field-widget-keyboard-focus/proposal.md
@@ -0,0 +1,28 @@
+## Why
+
+Optional Vaadin-backed field widgets expose a visible clear `×` that pointer users can activate but keyboard users cannot reach through Tab navigation.
+Property-editor validation rerenders can also remove focus from Save after the user tabs out of a changed field, causing the next Tab to restart at the editor instead of continuing through the action controls.
+
+## What Changes
+
+- Replace the non-tabbable internal Vaadin field clear affordance with a Causeway-owned, labelled, keyboard-focusable suffix button for eligible optional fields.
+- Preserve pointer clearing, pending-value updates, protected-value handling, field focus, and native fallback behavior.
+- Restore property action focus synchronously when validation rerenders replace Save or Cancel controls.
+- Add foundation regressions for clear-button semantics and validation-rerender focus continuity.
+- Add Petclinic browser coverage for the editor, clear, Save, and Cancel tab sequence and for Save focus surviving validation.
+
+## Capabilities
+
+### New Capabilities
+
+None.
+
+### Modified Capabilities
+
+- `vaadin-semantic-editor-families`: Require Causeway-owned keyboard operation for visible optional-field clearing.
+- `domain-web-components`: Require property-editor action focus to remain stable across validation rerenders.
+
+## Impact
+
+The change affects the internal field adapter, standard property interaction focus restoration, theme styling for the Causeway clear suffix, foundation tests, and Petclinic browser qualification.
+It does not change GraphQL operations, public Causeway element names, semantic value codecs, routes, CSP, dependencies, application markup, or the explicit-native rollback policy.
diff --git a/openspec/changes/fix-field-widget-keyboard-focus/specs/domain-web-components/spec.md b/openspec/changes/fix-field-widget-keyboard-focus/specs/domain-web-components/spec.md
new file mode 100644
index 00000000000..c3a8314e510
--- /dev/null
+++ b/openspec/changes/fix-field-widget-keyboard-focus/specs/domain-web-components/spec.md
@@ -0,0 +1,20 @@
+## MODIFIED Requirements
+
+### Requirement: Accessible standard interaction presentation
+Standard property editors and the standard action prompt SHALL expose labelled controls, associated validation, pending and error announcements, deterministic focus behavior, keyboard operation, and application styling through light-DOM semantic markup.
+
+#### Scenario: Parameterized prompt opens and closes
+- **WHEN** a keyboard user opens a parameterized action prompt
+- **THEN** focus moves to the first operable prompt control
+- **AND** Escape cancels the prompt without invocation
+- **AND** focus returns to the originating action affordance
+
+#### Scenario: Invalid property value
+- **WHEN** server validation rejects a pending property value
+- **THEN** the editor associates the reason with its input and announces it accessibly
+- **AND** retains the pending value for correction or cancellation
+
+#### Scenario: Property validation replaces focused actions
+- **WHEN** a user tabs from a changed property editor to Save or Cancel and validation-driven rendering replaces that focused action
+- **THEN** focus remains on the equivalent newly rendered action
+- **AND** subsequent Tab or Shift+Tab navigation continues from that action without restarting at the editor
diff --git a/openspec/changes/fix-field-widget-keyboard-focus/specs/vaadin-semantic-editor-families/spec.md b/openspec/changes/fix-field-widget-keyboard-focus/specs/vaadin-semantic-editor-families/spec.md
new file mode 100644
index 00000000000..7c6b894ea9d
--- /dev/null
+++ b/openspec/changes/fix-field-widget-keyboard-focus/specs/vaadin-semantic-editor-families/spec.md
@@ -0,0 +1,36 @@
+## MODIFIED Requirements
+
+### Requirement: Causeway-owned interaction semantics
+Each field adapter SHALL map Causeway labels, descriptions, required and disabled state, validation, pending values, focus, keyboard clearing, cancellation, and semantic events into its internal control.
+It MUST NOT establish a second interaction or validation state machine.
+
+#### Scenario: User changes an editable property
+- **WHEN** an internal control emits a value change
+- **THEN** the owning Causeway property interaction parses, validates, and saves through its existing context
+- **AND** success, failure, cancellation, focus restoration, and semantic events match native behavior
+
+#### Scenario: User changes an action parameter
+- **WHEN** an internal control changes a prepared object or service action parameter
+- **THEN** the interaction controller updates that parameter through the existing argument negotiation path
+- **AND** dependent parameter preparation and submission emit only advertised arguments
+
+#### Scenario: Optional field exposes clearing
+- **WHEN** a qualified optional non-protected field has a non-empty value and presents a visible clear affordance
+- **THEN** keyboard users can reach that affordance through normal forward and reverse Tab navigation
+- **AND** its accessible name identifies the semantic field being cleared
+- **AND** keyboard or pointer activation clears through the existing Causeway pending-value path
+
+#### Scenario: Keyboard user clears a field
+- **WHEN** the keyboard user activates the Causeway-owned clear affordance
+- **THEN** the now-empty clear affordance is removed from the tab sequence
+- **AND** focus returns to the field without cancelling the interaction, submitting it, or exposing a second value state
+
+#### Scenario: Validation rejects a value
+- **WHEN** client codec or authoritative GraphQL validation rejects the pending value
+- **THEN** the Causeway host owns the bounded error and invalid state
+- **AND** the internal control cannot submit or display a successful-looking alternative value
+
+#### Scenario: Protected text is edited
+- **WHEN** a protected semantic editor is prepared, changed, validated, cancelled, fails, or submits
+- **THEN** its prior or pending value is absent from markup, semantic events, errors, diagnostics, operation summaries, and route evidence
+- **AND** the internal control initializes empty with appropriate password-autocomplete behavior
diff --git a/openspec/changes/fix-field-widget-keyboard-focus/tasks.md b/openspec/changes/fix-field-widget-keyboard-focus/tasks.md
new file mode 100644
index 00000000000..10076fc46bb
--- /dev/null
+++ b/openspec/changes/fix-field-widget-keyboard-focus/tasks.md
@@ -0,0 +1,28 @@
+## 1. Baseline and regressions
+
+- [ ] 1.1 Record the non-tabbable Vaadin clear control and disappearing Save focus against unchanged authority and security boundaries.
+- [ ] 1.2 Add field-widget coverage for a labelled tabbable suffix clear button, activation, visibility, and focus return.
+- [ ] 1.3 Add property-interaction coverage for Save and Cancel focus across consecutive validation renders.
+- [ ] 1.4 Add Petclinic browser coverage for editor, clear, Save, and Cancel keyboard order and Save focus persistence.
+
+## 2. Keyboard-operable clearing
+
+- [ ] 2.1 Disable the qualified field's non-tabbable internal Vaadin clear control.
+- [ ] 2.2 Add a Causeway-owned native button through the supported suffix slot with a bounded accessible name.
+- [ ] 2.3 Clear through the existing bubbling pending-value path and return focus to the field.
+- [ ] 2.4 Synchronize clear visibility for initial, programmatic, input, and change values.
+- [ ] 2.5 Exclude required, protected, disabled, and unsupported controls while preserving native fallback.
+- [ ] 2.6 Add CSP-safe semantic styling for the clear suffix.
+
+## 3. Property action focus
+
+- [ ] 3.1 Restore focused Save or Cancel synchronously after property interaction markup replacement.
+- [ ] 3.2 Retain deferred editor and selection restoration for lazy toolkit controls.
+- [ ] 3.3 Preserve validation, cancellation, semantic events, associated actions, and external focus departure.
+
+## 4. Qualification
+
+- [ ] 4.1 Run the complete foundation and HTMX route-policy suites.
+- [ ] 4.2 Run focused Petclinic Java integration tests.
+- [ ] 4.3 Run Petclinic Playwright under Vaadin-default and explicit-native policies.
+- [ ] 4.4 Run RAT, ordinary packaging, strict OpenSpec validation, and whitespace checks.
(causeway) 04/10: archives field widget keyboard focus fixes
Posted by da...@apache.org.
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 a73fe20fe8e551a63568a3b675fbdf216a1d8986
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Aug 26 21:30:31 2026 +0100
archives field widget keyboard focus fixes
---
.../.openspec.yaml | 0
.../2026-08-26-fix-field-widget-keyboard-focus}/design.md | 0
.../evidence/baseline-and-boundaries.md | 0
.../evidence/implementation-and-qualification.md | 0
.../2026-08-26-fix-field-widget-keyboard-focus}/proposal.md | 0
.../specs/domain-web-components/spec.md | 0
.../specs/vaadin-semantic-editor-families/spec.md | 0
.../2026-08-26-fix-field-widget-keyboard-focus}/tasks.md | 0
openspec/specs/domain-web-components/spec.md | 5 +++++
openspec/specs/vaadin-semantic-editor-families/spec.md | 13 ++++++++++++-
10 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/openspec/changes/fix-field-widget-keyboard-focus/.openspec.yaml b/openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/.openspec.yaml
similarity index 100%
rename from openspec/changes/fix-field-widget-keyboard-focus/.openspec.yaml
rename to openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/.openspec.yaml
diff --git a/openspec/changes/fix-field-widget-keyboard-focus/design.md b/openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/design.md
similarity index 100%
rename from openspec/changes/fix-field-widget-keyboard-focus/design.md
rename to openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/design.md
diff --git a/openspec/changes/fix-field-widget-keyboard-focus/evidence/baseline-and-boundaries.md b/openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/evidence/baseline-and-boundaries.md
similarity index 100%
rename from openspec/changes/fix-field-widget-keyboard-focus/evidence/baseline-and-boundaries.md
rename to openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/evidence/baseline-and-boundaries.md
diff --git a/openspec/changes/fix-field-widget-keyboard-focus/evidence/implementation-and-qualification.md b/openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/evidence/implementation-and-qualification.md
similarity index 100%
rename from openspec/changes/fix-field-widget-keyboard-focus/evidence/implementation-and-qualification.md
rename to openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/evidence/implementation-and-qualification.md
diff --git a/openspec/changes/fix-field-widget-keyboard-focus/proposal.md b/openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/proposal.md
similarity index 100%
rename from openspec/changes/fix-field-widget-keyboard-focus/proposal.md
rename to openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/proposal.md
diff --git a/openspec/changes/fix-field-widget-keyboard-focus/specs/domain-web-components/spec.md b/openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/specs/domain-web-components/spec.md
similarity index 100%
rename from openspec/changes/fix-field-widget-keyboard-focus/specs/domain-web-components/spec.md
rename to openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/specs/domain-web-components/spec.md
diff --git a/openspec/changes/fix-field-widget-keyboard-focus/specs/vaadin-semantic-editor-families/spec.md b/openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/specs/vaadin-semantic-editor-families/spec.md
similarity index 100%
rename from openspec/changes/fix-field-widget-keyboard-focus/specs/vaadin-semantic-editor-families/spec.md
rename to openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/specs/vaadin-semantic-editor-families/spec.md
diff --git a/openspec/changes/fix-field-widget-keyboard-focus/tasks.md b/openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/tasks.md
similarity index 100%
rename from openspec/changes/fix-field-widget-keyboard-focus/tasks.md
rename to openspec/changes/archive/2026-08-26-fix-field-widget-keyboard-focus/tasks.md
diff --git a/openspec/specs/domain-web-components/spec.md b/openspec/specs/domain-web-components/spec.md
index 8150ffb582a..6bfe839026d 100644
--- a/openspec/specs/domain-web-components/spec.md
+++ b/openspec/specs/domain-web-components/spec.md
@@ -504,6 +504,11 @@ Standard property editors and the standard action prompt SHALL expose labelled c
- **THEN** the editor associates the reason with its input and announces it accessibly
- **AND** retains the pending value for correction or cancellation
+#### Scenario: Property validation replaces focused actions
+- **WHEN** a user tabs from a changed property editor to Save or Cancel and validation-driven rendering replaces that focused action
+- **THEN** focus remains on the equivalent newly rendered action
+- **AND** subsequent Tab or Shift+Tab navigation continues from that action without restarting at the editor
+
### Requirement: Executable vanilla-HTML interaction acceptance composition
The interaction slice SHALL extend the existing `sample-html` application as an executable acceptance fixture using the packaged web-component artifact and the real same-origin rich GraphQL endpoint.
diff --git a/openspec/specs/vaadin-semantic-editor-families/spec.md b/openspec/specs/vaadin-semantic-editor-families/spec.md
index e518e3b60dd..c20dc7eb732 100644
--- a/openspec/specs/vaadin-semantic-editor-families/spec.md
+++ b/openspec/specs/vaadin-semantic-editor-families/spec.md
@@ -36,7 +36,7 @@ Application markup and events MUST remain Causeway-owned and MUST NOT require ra
- **AND** no field closure is imported
### Requirement: Causeway-owned interaction semantics
-Each field adapter SHALL map Causeway labels, descriptions, required and disabled state, validation, pending values, focus, cancellation, and semantic events into its internal control.
+Each field adapter SHALL map Causeway labels, descriptions, required and disabled state, validation, pending values, focus, keyboard clearing, cancellation, and semantic events into its internal control.
It MUST NOT establish a second interaction or validation state machine.
#### Scenario: User changes an editable property
@@ -49,6 +49,17 @@ It MUST NOT establish a second interaction or validation state machine.
- **THEN** the interaction controller updates that parameter through the existing argument negotiation path
- **AND** dependent parameter preparation and submission emit only advertised arguments
+#### Scenario: Optional field exposes clearing
+- **WHEN** a qualified optional non-protected field has a non-empty value and presents a visible clear affordance
+- **THEN** keyboard users can reach that affordance through normal forward and reverse Tab navigation
+- **AND** its accessible name identifies the semantic field being cleared
+- **AND** keyboard or pointer activation clears through the existing Causeway pending-value path
+
+#### Scenario: Keyboard user clears a field
+- **WHEN** the keyboard user activates the Causeway-owned clear affordance
+- **THEN** the now-empty clear affordance is removed from the tab sequence
+- **AND** focus returns to the field without cancelling the interaction, submitting it, or exposing a second value state
+
#### Scenario: Validation rejects a value
- **WHEN** client codec or authoritative GraphQL validation rejects the pending value
- **THEN** the Causeway host owns the bounded error and invalid state
(causeway) 08/10: docs(openspec): plan deleted void action navigation fix
Posted by da...@apache.org.
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 4d3af1a5b535fa2bac1f633a7291fd86e74986de
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Thu Aug 27 11:12:19 2026 +0200
docs(openspec): plan deleted void action navigation fix
---
.../.openspec.yaml | 2 ++
.../fix-deleted-void-action-navigation/design.md | 36 ++++++++++++++++++++++
.../fix-deleted-void-action-navigation/proposal.md | 26 ++++++++++++++++
.../generic-htmx-web-component-viewer/spec.md | 20 ++++++++++++
.../fix-deleted-void-action-navigation/tasks.md | 10 ++++++
5 files changed, 94 insertions(+)
diff --git a/openspec/changes/fix-deleted-void-action-navigation/.openspec.yaml b/openspec/changes/fix-deleted-void-action-navigation/.openspec.yaml
new file mode 100644
index 00000000000..f05b045c8af
--- /dev/null
+++ b/openspec/changes/fix-deleted-void-action-navigation/.openspec.yaml
@@ -0,0 +1,2 @@
+schema: spec-driven
+created: 2026-08-27
diff --git a/openspec/changes/fix-deleted-void-action-navigation/design.md b/openspec/changes/fix-deleted-void-action-navigation/design.md
new file mode 100644
index 00000000000..b05905ac2fd
--- /dev/null
+++ b/openspec/changes/fix-deleted-void-action-navigation/design.md
@@ -0,0 +1,36 @@
+## Context
+
+The interaction controller publishes a successful semantic result for a void action and refreshes the owning object context when the action is mutating.
+The HTMX host also reloads the current route so ordinary void mutations display refreshed object state while preserving the shell result.
+If the action deleted the target, that reload creates a new context for an identity that no longer resolves, leaving the user on an error-filled object page.
+
+## Goals / Non-Goals
+
+**Goals:**
+
+- Preserve same-object refresh for ordinary successful void actions.
+- Route to the configured viewer home path when the post-void refresh establishes that the current object was deleted.
+- Keep the successful action result visible long enough to confirm completion.
+- Cover the behavior through the existing destructive Petclinic browser journey.
+
+**Non-Goals:**
+
+- Change semantic void-result payloads or require domain actions to declare that they delete their target.
+- Redirect arbitrary direct navigation to missing objects.
+- Change navigation for object, collection, or scalar action results.
+
+## Decisions
+
+The HTMX host will remember that a void-result route refresh is pending and associate that state with the refreshed route generation.
+When the refreshed route's object context reaches a terminal `NOT_FOUND` state, the host will navigate to the normalized viewer base path.
+The marker will be cleared when the refreshed object becomes ready, partially ready, or fails for a reason other than not-found, so unrelated later failures cannot cause a home redirect.
+This uses runtime evidence from the refreshed object rather than action names such as `delete`, which keeps the policy generic and avoids coupling the viewer to domain conventions.
+
+The Petclinic Playwright journey will assert navigation to `/htmx` after `PetOwner#delete`, while retaining its repository assertion that the object was actually removed.
+A focused browser-side test is not introduced because the shell module currently depends on live DOM and HTMX wiring; the existing end-to-end journey directly covers the reported regression.
+
+## Risks / Trade-offs
+
+- [Risk] The original object context may publish `NOT_FOUND` while the route refresh is in flight. → Bind recovery to the navigation generation and only act on a context contained by the current route region.
+- [Risk] A transient or authorization failure could be mistaken for deletion. → Redirect only for the explicit `NOT_FOUND` classification and retain existing bounded handling for all other failures.
+- [Risk] The successful result message is cleared by the home navigation. → Preserve it during the recovery navigation so users retain confirmation that the action completed.
diff --git a/openspec/changes/fix-deleted-void-action-navigation/proposal.md b/openspec/changes/fix-deleted-void-action-navigation/proposal.md
new file mode 100644
index 00000000000..1dd6201c136
--- /dev/null
+++ b/openspec/changes/fix-deleted-void-action-navigation/proposal.md
@@ -0,0 +1,26 @@
+## Why
+
+Void actions normally refresh the current object route, but that behavior leaves a deleted object page in a terminal error state when the action removed its target.
+The generic HTMX Web Components viewer should recover from this specific post-action condition by returning the user to the viewer home page.
+
+## What Changes
+
+- Track when the viewer is refreshing an object route after a successful void action.
+- If that refresh reports that the object no longer exists, navigate to the viewer home route instead of leaving the deleted object page visible.
+- Preserve current-route refresh behavior for successful void actions whose target still exists.
+- Add browser regression coverage using `PetOwner#delete`.
+
+## Capabilities
+
+### New Capabilities
+
+None.
+
+### Modified Capabilities
+
+- `generic-htmx-web-component-viewer`: Define home-route fallback when a void action deletes the object represented by the current route.
+
+## Impact
+
+The change affects the generic HTMX viewer's browser-side action-result and object-state routing policy, plus the Petclinic Playwright journey for destructive object actions.
+It does not change GraphQL action-result semantics or application domain APIs.
diff --git a/openspec/changes/fix-deleted-void-action-navigation/specs/generic-htmx-web-component-viewer/spec.md b/openspec/changes/fix-deleted-void-action-navigation/specs/generic-htmx-web-component-viewer/spec.md
new file mode 100644
index 00000000000..da9f09ebf64
--- /dev/null
+++ b/openspec/changes/fix-deleted-void-action-navigation/specs/generic-htmx-web-component-viewer/spec.md
@@ -0,0 +1,20 @@
+## ADDED Requirements
+
+### Requirement: Void action route recovery
+The viewer SHALL refresh the current object route after a successful void action while the object remains available, and SHALL return to its configured home route when that post-action refresh establishes that the object no longer exists.
+The fallback MUST be limited to the current post-action refresh and MUST NOT convert unrelated missing-object navigation into a home redirect.
+
+#### Scenario: Void action retains its target
+- **WHEN** a successful void action completes and the current object remains available
+- **THEN** the viewer refreshes the current object route
+- **AND** presents the updated object state on the same canonical route
+
+#### Scenario: Void action deletes its target
+- **WHEN** a successful void action completes and the refreshed current object reports `NOT_FOUND`
+- **THEN** the viewer navigates to the configured home route
+- **AND** does not leave the deleted object page in a terminal or component-error state
+
+#### Scenario: Missing object is requested independently
+- **WHEN** an object route reports `NOT_FOUND` without a current successful void-action refresh
+- **THEN** the viewer retains its bounded missing-object state
+- **AND** does not redirect to the home route
diff --git a/openspec/changes/fix-deleted-void-action-navigation/tasks.md b/openspec/changes/fix-deleted-void-action-navigation/tasks.md
new file mode 100644
index 00000000000..79ce5dcaf2a
--- /dev/null
+++ b/openspec/changes/fix-deleted-void-action-navigation/tasks.md
@@ -0,0 +1,10 @@
+## 1. Viewer Routing
+
+- [ ] 1.1 Track the current void-action route refresh in the HTMX shell without affecting unrelated navigation.
+- [ ] 1.2 Redirect a matching post-action `NOT_FOUND` object state to the configured home route while preserving the successful result.
+- [ ] 1.3 Clear post-action recovery state when the target remains available or a different terminal condition occurs.
+
+## 2. Regression Coverage
+
+- [ ] 2.1 Update the Petclinic destructive Playwright journey to assert home navigation after `PetOwner#delete`.
+- [ ] 2.2 Run focused HTMX viewer and Petclinic validation checks.
(causeway) 06/10: preserves field clear focus during validation
Posted by da...@apache.org.
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 78531038e650f24ee2537f428e405e680c7238ed
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Aug 26 22:38:37 2026 +0100
preserves field clear focus during validation
---
.../evidence/baseline-and-boundaries.md | 21 ++++++++
.../evidence/implementation-and-qualification.md | 33 ++++++++++++
.../changes/preserve-field-clear-focus/tasks.md | 32 +++++------
.../webcomponents/foundation/src/field-widget.mjs | 21 ++++++++
.../foundation/src/property-element.mjs | 23 +++++++-
.../foundation/test/field-widget.test.mjs | 28 ++++++++++
.../foundation/test/interaction.test.mjs | 62 ++++++++++++++++++++++
.../petclinic/PetClinicHtmxPlaywrightTest.java | 2 +
8 files changed, 205 insertions(+), 17 deletions(-)
diff --git a/openspec/changes/preserve-field-clear-focus/evidence/baseline-and-boundaries.md b/openspec/changes/preserve-field-clear-focus/evidence/baseline-and-boundaries.md
new file mode 100644
index 00000000000..a9f3eb50dcf
--- /dev/null
+++ b/openspec/changes/preserve-field-clear-focus/evidence/baseline-and-boundaries.md
@@ -0,0 +1,21 @@
+# Baseline and boundaries
+
+## Reproduced defect
+
+After Edit Known As focuses the field, typing schedules debounced authoritative validation.
+Tab moves focus to the Causeway clear `×`, but the brief transition near the “Editing” status shows the property entering and leaving validation.
+Those consecutive renders replace the asynchronously upgraded field adapter while its suffix owns focus.
+The first replacement temporarily leaves body focus active, the second no longer infers Clear as the intended target, and the next Tab restarts at the field.
+
+The prior browser regression moved immediately from Clear to Save and therefore did not hold Clear long enough to expose the validation lifecycle.
+The strengthened regression pauses for validation and fails against the pre-change implementation because active focus becomes the body.
+
+## Preserved boundaries
+
+- GraphQL remains authoritative for property validation and mutation.
+- Validation debounce, status announcements, error semantics, and the visible validating/editing transition remain unchanged.
+- Causeway retains ownership of public elements, focus policy, clear semantics, cancellation, and events.
+- The adapter uses no private Vaadin shadow access and exposes no raw toolkit API to applications.
+- Clear focus is restored only for a connected visible suffix carrying a current property-owned intent.
+- Genuine external focus departure clears that intent and is never reversed.
+- Save/Cancel restoration, editor selection restoration, protected-value filtering, native fallback, strict CSP, routes, and packaging remain unchanged.
diff --git a/openspec/changes/preserve-field-clear-focus/evidence/implementation-and-qualification.md b/openspec/changes/preserve-field-clear-focus/evidence/implementation-and-qualification.md
new file mode 100644
index 00000000000..67f65f89f3c
--- /dev/null
+++ b/openspec/changes/preserve-field-clear-focus/evidence/implementation-and-qualification.md
@@ -0,0 +1,33 @@
+# Implementation and qualification
+
+## Implementation
+
+The internal field adapter now accepts `focusClear()` before or after toolkit upgrade.
+It retains the request while no control exists, then focuses only a connected visible Causeway clear suffix after installation.
+An empty or ineligible field expires the adapter request without moving focus, and generation/disconnection checks continue to reject stale adapters.
+
+The property now tracks clear focus independently through local `focusin` and `focusout` events.
+Removing the focused suffix during property-owned rendering does not erase the intent.
+While consecutive validating and editing renders temporarily leave body focus active, each replacement `<causeway-field-editor>` receives the same clear-focus request.
+Focus entering the editor, Save, Cancel, or another owned control clears the intent, as does genuine focus departure beyond the property.
+
+Save/Cancel synchronous restoration and deferred editor selection restoration remain unchanged.
+The validating/editing status transition and its brief visual update remain semantically unchanged; only focus continuity is corrected.
+
+## Qualification
+
+- Focused field-widget suite: 10 passed, zero failed.
+- Focused interaction suite: 19 passed, zero failed.
+- Complete foundation Node suite: 177 passed, zero failed.
+- HTMX route-policy Node suite: 5 passed, zero failed.
+- Petclinic Java integration suite: passed.
+- Focused browser regression holds Clear for 750 ms through validation, then continues to Save: passed.
+- Complete Petclinic Vaadin-default Playwright matrix: 4 passed, zero failed.
+- Complete Petclinic explicit-native Playwright matrix: 4 passed, zero failed.
+- Foundation RAT check: passed.
+- Petclinic RAT check: passed.
+- Ordinary reactor packaging: passed and produced a 53,891-byte Petclinic jar without `BOOT-INF`.
+- Strict OpenSpec validation: passed.
+- Git whitespace validation: passed.
+
+No GraphQL, validation timing, status announcement, public element, semantic event, route, CSP, dependency, toolkit asset, protected-value, or native-fallback contract changed.
diff --git a/openspec/changes/preserve-field-clear-focus/tasks.md b/openspec/changes/preserve-field-clear-focus/tasks.md
index 2cbd982700d..63cf26c595a 100644
--- a/openspec/changes/preserve-field-clear-focus/tasks.md
+++ b/openspec/changes/preserve-field-clear-focus/tasks.md
@@ -1,27 +1,27 @@
## 1. Baseline and regressions
-- [ ] 1.1 Record clear-focus loss, the validation status flash, and unchanged authority/security boundaries.
-- [ ] 1.2 Extend field-widget tests for clear-focus requests before and after asynchronous upgrade.
-- [ ] 1.3 Extend property tests for clear intent across consecutive renders and genuine external departure.
-- [ ] 1.4 Extend Petclinic browser coverage to hold Clear focus through validation and continue to Save.
+- [x] 1.1 Record clear-focus loss, the validation status flash, and unchanged authority/security boundaries.
+- [x] 1.2 Extend field-widget tests for clear-focus requests before and after asynchronous upgrade.
+- [x] 1.3 Extend property tests for clear intent across consecutive renders and genuine external departure.
+- [x] 1.4 Extend Petclinic browser coverage to hold Clear focus through validation and continue to Save.
## 2. Adapter clear-focus lifecycle
-- [ ] 2.1 Add an internal field-adapter method that requests clear focus before or after upgrade.
-- [ ] 2.2 Focus only a connected visible clear suffix after upgrade and safely expire inapplicable requests.
-- [ ] 2.3 Preserve generation, disconnection, protected-value, and native-fallback behavior.
+- [x] 2.1 Add an internal field-adapter method that requests clear focus before or after upgrade.
+- [x] 2.2 Focus only a connected visible clear suffix after upgrade and safely expire inapplicable requests.
+- [x] 2.3 Preserve generation, disconnection, protected-value, and native-fallback behavior.
## 3. Property focus intent
-- [ ] 3.1 Track focus entering the Causeway clear suffix independently from editor and action focus.
-- [ ] 3.2 Preserve clear intent while property-owned rendering temporarily leaves body focus active.
-- [ ] 3.3 Forward clear intent to each replacement adapter across validating and editing renders.
-- [ ] 3.4 Clear intent when focus moves to another owned control or genuinely leaves the property.
-- [ ] 3.5 Preserve Save/Cancel restoration, deferred editor selection, validation, cancellation, and external focus.
+- [x] 3.1 Track focus entering the Causeway clear suffix independently from editor and action focus.
+- [x] 3.2 Preserve clear intent while property-owned rendering temporarily leaves body focus active.
+- [x] 3.3 Forward clear intent to each replacement adapter across validating and editing renders.
+- [x] 3.4 Clear intent when focus moves to another owned control or genuinely leaves the property.
+- [x] 3.5 Preserve Save/Cancel restoration, deferred editor selection, validation, cancellation, and external focus.
## 4. Qualification
-- [ ] 4.1 Run the complete foundation and HTMX route-policy suites.
-- [ ] 4.2 Run focused Petclinic Java integration tests.
-- [ ] 4.3 Run Petclinic Playwright under Vaadin-default and explicit-native policies.
-- [ ] 4.4 Run RAT, ordinary packaging, strict OpenSpec validation, and whitespace checks.
+- [x] 4.1 Run the complete foundation and HTMX route-policy suites.
+- [x] 4.2 Run focused Petclinic Java integration tests.
+- [x] 4.3 Run Petclinic Playwright under Vaadin-default and explicit-native policies.
+- [x] 4.4 Run RAT, ordinary packaging, strict OpenSpec validation, and whitespace checks.
diff --git a/viewers/webcomponents/foundation/src/field-widget.mjs b/viewers/webcomponents/foundation/src/field-widget.mjs
index e154be586d5..dc7faad8976 100644
--- a/viewers/webcomponents/foundation/src/field-widget.mjs
+++ b/viewers/webcomponents/foundation/src/field-widget.mjs
@@ -141,6 +141,7 @@ export class CausewayFieldEditorElement extends HTMLElement {
this._clearButton = null;
this._generation = 0;
this._focusRequested = false;
+ this._clearFocusRequested = false;
this.addEventListener('keydown', event => {
if (event.key === 'Escape') {
this.dispatchEvent(new CustomEvent('causeway-field-escape', {bubbles: true, composed: true}));
@@ -158,6 +159,7 @@ export class CausewayFieldEditorElement extends HTMLElement {
this._generation += 1;
this._control = null;
this._clearButton = null;
+ this._clearFocusRequested = false;
}
get value() {
@@ -196,6 +198,11 @@ export class CausewayFieldEditorElement extends HTMLElement {
this._control?.focus?.(options);
}
+ focusClear(options) {
+ this._clearFocusRequested = true;
+ this.#restoreClearFocus(options);
+ }
+
async #upgrade(generation) {
const family = this.dataset.family;
const tagName = `vaadin-${this.dataset.control}`;
@@ -274,6 +281,7 @@ export class CausewayFieldEditorElement extends HTMLElement {
this.#refreshClearButton();
this.dataset.widgetState = 'ready';
if (this._focusRequested) queueMicrotask(() => control.focus());
+ this.#restoreClearFocus();
} catch (error) {
if (!this.isConnected || generation !== this._generation) return;
failCausewayFieldFamily(family);
@@ -320,6 +328,19 @@ export class CausewayFieldEditorElement extends HTMLElement {
}
}
+ #restoreClearFocus(options) {
+ if (!this._clearFocusRequested || !this._control) {
+ return;
+ }
+ const clearButton = this._clearButton;
+ this._clearFocusRequested = false;
+ if (clearButton?.isConnected && !clearButton.hidden) {
+ queueMicrotask(() => {
+ if (clearButton.isConnected && !clearButton.hidden) clearButton.focus(options);
+ });
+ }
+ }
+
#items() {
try {
const items = JSON.parse(this.dataset.items || '[]');
diff --git a/viewers/webcomponents/foundation/src/property-element.mjs b/viewers/webcomponents/foundation/src/property-element.mjs
index bf9f5810447..9ab6ee41e74 100644
--- a/viewers/webcomponents/foundation/src/property-element.mjs
+++ b/viewers/webcomponents/foundation/src/property-element.mjs
@@ -62,6 +62,15 @@ export class CausewayPropertyElement extends CausewayContextConsumerElement {
this.autoCompleteGeneration = 0;
this.renderingInteraction = false;
this.restoreEditFocusAfterGeneration = null;
+ this.restoreClearFocus = false;
+ this.addEventListener('focusin', event => {
+ this.restoreClearFocus = event.target?.hasAttribute?.('data-causeway-field-clear') === true;
+ });
+ this.addEventListener('focusout', event => {
+ if (!this.renderingInteraction && !this.contains(event.relatedTarget)) {
+ this.restoreClearFocus = false;
+ }
+ });
this.addEventListener('click', event => {
if (eventOriginatesFromAssociatedAction(this, event.target)) {
return;
@@ -200,6 +209,7 @@ export class CausewayPropertyElement extends CausewayContextConsumerElement {
}
if (name === 'member') {
this.interactionState = null;
+ this.restoreClearFocus = false;
refreshMemberComposition(this);
this.reconnectRequirement();
} else {
@@ -217,6 +227,7 @@ export class CausewayPropertyElement extends CausewayContextConsumerElement {
return false;
}
this.restoreEditFocusAfterGeneration = null;
+ this.restoreClearFocus = false;
const generation = ++this.interactionGeneration;
this.#setInteraction({status: InteractionStatus.PREPARING, pendingValue: state.data?.get, error: null});
const result = await this._resolvedContext.prepareProperty(this.member);
@@ -274,6 +285,7 @@ export class CausewayPropertyElement extends CausewayContextConsumerElement {
const editor = this.interactionState.editor;
this.interactionState = null;
this.restoreEditFocusAfterGeneration = null;
+ this.restoreClearFocus = false;
this.dispatchEvent(createSemanticEvent(CausewaySemanticEvent.PROPERTY_INTERACTION_STATE, Object.freeze({
member: this.member,
status: InteractionStatus.CANCELLED,
@@ -417,6 +429,7 @@ export class CausewayPropertyElement extends CausewayContextConsumerElement {
this.restoreEditFocusAfterGeneration = focusGeneration;
const editor = this.interactionState.editor;
this.interactionState = null;
+ this.restoreClearFocus = false;
this.dispatchEvent(createSemanticEvent(CausewaySemanticEvent.PROPERTY_UPDATED, Object.freeze({
member: this.member,
value: publicInteractionValue(editor, pendingValue),
@@ -585,6 +598,12 @@ export class CausewayPropertyElement extends CausewayContextConsumerElement {
const ownsFocus = typeof this.contains === 'function' && this.contains(activeElement);
const activeEditor = ownsFocus && activeElement?.getAttribute?.('data-causeway-editor');
const activeAction = ownsFocus && activeElement?.getAttribute?.('data-causeway-action');
+ const activeClear = ownsFocus && activeElement?.hasAttribute?.('data-causeway-field-clear');
+ if (activeClear) {
+ this.restoreClearFocus = true;
+ } else if (ownsFocus && (activeEditor || activeAction)) {
+ this.restoreClearFocus = false;
+ }
const selectionStart = activeEditor ? activeElement.selectionStart : null;
const selectionEnd = activeEditor ? activeElement.selectionEnd : null;
const busy = [InteractionStatus.PREPARING, InteractionStatus.VALIDATING, InteractionStatus.SAVING].includes(interaction.status);
@@ -611,7 +630,9 @@ export class CausewayPropertyElement extends CausewayContextConsumerElement {
} finally {
this.renderingInteraction = false;
}
- if (activeAction) {
+ if (this.restoreClearFocus) {
+ this.querySelector?.('causeway-field-editor')?.focusClear?.();
+ } else if (activeAction) {
this.querySelector?.(`[data-causeway-action="${activeAction}"]`)?.focus?.();
} else if (activeEditor) {
queueMicrotask(() => {
diff --git a/viewers/webcomponents/foundation/test/field-widget.test.mjs b/viewers/webcomponents/foundation/test/field-widget.test.mjs
index 821a5fc5a12..89776ab792e 100644
--- a/viewers/webcomponents/foundation/test/field-widget.test.mjs
+++ b/viewers/webcomponents/foundation/test/field-widget.test.mjs
@@ -145,6 +145,7 @@ test('qualified optional fields expose a labelled keyboard clear suffix', async
let commitEvents = 0;
editor.addEventListener('input', () => { inputEvents += 1; });
editor.addEventListener('causeway-editor-commit', () => { commitEvents += 1; });
+ editor.focusClear();
document.body.appendChild(editor);
await new Promise(resolve => setTimeout(resolve, 0));
@@ -157,6 +158,8 @@ test('qualified optional fields expose a labelled keyboard clear suffix', async
assert.equal(clearButton.getAttribute('aria-label'), 'Clear Known As');
assert.equal(clearButton.getAttribute('data-testid'), 'known-as-editor-clear');
assert.equal(clearButton.hidden, false);
+ await Promise.resolve();
+ assert.equal(document.activeElement, clearButton);
const internalFocusout = new Event('focusout', {bubbles: true, composed: true});
internalFocusout.relatedTarget = clearButton;
@@ -172,6 +175,10 @@ test('qualified optional fields expose a labelled keyboard clear suffix', async
assert.equal(clearButton.hidden, true);
editor.value = 'Ada';
assert.equal(clearButton.hidden, false);
+ document.body.focus();
+ editor.focusClear();
+ await Promise.resolve();
+ assert.equal(document.activeElement, clearButton);
clearButton.focus();
clearButton.dispatchEvent(new Event('click', {bubbles: true, cancelable: true}));
@@ -182,6 +189,27 @@ test('qualified optional fields expose a labelled keyboard clear suffix', async
document.body.removeChild(editor);
});
+test('an inapplicable pre-upgrade clear focus request expires safely', async () => {
+ configureCausewayFieldWidgets({families: ['basic'], moduleUrls: {basic: fakeBasicModule}});
+ const editor = new CausewayFieldEditorElement();
+ editor.setAttribute('data-family', 'basic');
+ editor.setAttribute('data-control', 'text-field');
+ editor.setAttribute('data-causeway-editor', 'knownAs');
+ editor.setAttribute('data-label', 'Known As');
+ editor.setAttribute('data-value', '');
+ document.body.focus();
+ editor.focusClear();
+ document.body.appendChild(editor);
+ await new Promise(resolve => setTimeout(resolve, 0));
+ const clearButton = editor.childNodes[0].childNodes[0];
+ assert.equal(clearButton.hidden, true);
+ assert.equal(document.activeElement, document.body);
+ editor.value = 'Later';
+ await Promise.resolve();
+ assert.notEqual(document.activeElement, clearButton);
+ document.body.removeChild(editor);
+});
+
test('required disabled and protected fields omit the clear suffix', async () => {
configureCausewayFieldWidgets({families: ['basic'], moduleUrls: {basic: fakeBasicModule}});
for (const attributes of [
diff --git a/viewers/webcomponents/foundation/test/interaction.test.mjs b/viewers/webcomponents/foundation/test/interaction.test.mjs
index 5e350fbff57..f3d32fcca79 100644
--- a/viewers/webcomponents/foundation/test/interaction.test.mjs
+++ b/viewers/webcomponents/foundation/test/interaction.test.mjs
@@ -457,6 +457,68 @@ test('property validation preserves Save and Cancel focus across consecutive ren
}
});
+test('property preserves clear focus intent across validation renders but not external departure', async () => {
+ let stateListener;
+ const validationResolvers = [];
+ const context = {
+ registerRequirement(requirement, listener) {
+ stateListener = listener;
+ return () => {};
+ },
+ async prepareProperty() {
+ return {status: 'success', data: {capabilities: {validate: true, inputType: scalar('String'), enumValues: []}, choices: []}, errors: []};
+ },
+ async validateProperty() {
+ return new Promise(resolve => validationResolvers.push(resolve));
+ }
+ };
+ const property = new CausewayPropertyElement();
+ property.member = 'knownAs';
+ property.editable = true;
+ property.context = context;
+ document.body.appendChild(property);
+ stateListener({
+ status: 'ready',
+ descriptor: {id: 'knownAs', description: '', value: {typeRef: scalar('String')}},
+ data: {hidden: false, disabled: null, get: 'Original'}, errors: [], generation: 1
+ });
+ assert.equal(await property.beginEdit(), true);
+ await Promise.resolve();
+
+ const oldClear = document.createElement('button');
+ oldClear.setAttribute('data-causeway-field-clear', '');
+ property.appendChild(oldClear);
+ const firstAdapter = {requests: 0, focusClear() { this.requests += 1; }};
+ let replacementAdapter = firstAdapter;
+ property.querySelector = selector => selector === 'causeway-field-editor' ? replacementAdapter : null;
+ oldClear.focus();
+ property.setPendingValue('Changed');
+
+ const validation = property.validatePending();
+ assert.equal(firstAdapter.requests, 1);
+ document.body.focus();
+ const secondAdapter = {requests: 0, focusClear() { this.requests += 1; }};
+ replacementAdapter = secondAdapter;
+ validationResolvers.shift()({status: 'success', data: null, errors: []});
+ await validation;
+ assert.equal(secondAdapter.requests, 1);
+
+ const external = document.createElement('button');
+ external.focus();
+ const departure = new Event('focusout', {bubbles: true});
+ departure.relatedTarget = external;
+ property.dispatchEvent(departure);
+ const thirdAdapter = {requests: 0, focusClear() { this.requests += 1; }};
+ replacementAdapter = thirdAdapter;
+ property.setPendingValue('Again');
+ const laterValidation = property.validatePending();
+ assert.equal(thirdAdapter.requests, 0);
+ validationResolvers.shift()({status: 'success', data: null, errors: []});
+ await laterValidation;
+ assert.equal(thirdAdapter.requests, 0);
+ document.body.removeChild(property);
+});
+
test('windowed Vaadin reference adapter requests authoritative later pages', async () => {
const moduleSource = `
if (!globalThis.customElements.get('vaadin-combo-box')) globalThis.customElements.define('vaadin-combo-box', class extends HTMLElement {});
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 3330d73990f..ab6d32ff392 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
@@ -352,6 +352,8 @@ void propertyEditingAndPromptFocusRemainDeterministic() {
fillEditor(knownAsEditor, "Keyboard focus");
knownAsEditor.press("Tab");
assertFocused(knownAsClearSelector);
+ page.waitForTimeout(750);
+ assertFocused(knownAsClearSelector);
page.locator(knownAsClearSelector).press("Tab");
} else {
fillEditor(knownAsEditor, "Keyboard focus");
(causeway) 05/10: plans preserved field clear focus
Posted by da...@apache.org.
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 321c26f6e2c4bc8e485e6ec48e77a17273cc52b3
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Aug 26 22:32:19 2026 +0100
plans preserved field clear focus
---
.../preserve-field-clear-focus/.openspec.yaml | 2 +
.../changes/preserve-field-clear-focus/design.md | 62 ++++++++++++++++++++++
.../changes/preserve-field-clear-focus/proposal.md | 28 ++++++++++
.../specs/domain-web-components/spec.md | 25 +++++++++
.../specs/vaadin-semantic-editor-families/spec.md | 41 ++++++++++++++
.../changes/preserve-field-clear-focus/tasks.md | 27 ++++++++++
6 files changed, 185 insertions(+)
diff --git a/openspec/changes/preserve-field-clear-focus/.openspec.yaml b/openspec/changes/preserve-field-clear-focus/.openspec.yaml
new file mode 100644
index 00000000000..701445b8918
--- /dev/null
+++ b/openspec/changes/preserve-field-clear-focus/.openspec.yaml
@@ -0,0 +1,2 @@
+schema: spec-driven
+created: 2026-08-26
diff --git a/openspec/changes/preserve-field-clear-focus/design.md b/openspec/changes/preserve-field-clear-focus/design.md
new file mode 100644
index 00000000000..528df6b70f5
--- /dev/null
+++ b/openspec/changes/preserve-field-clear-focus/design.md
@@ -0,0 +1,62 @@
+## Context
+
+Typing in a debounced property editor schedules authoritative validation.
+When the user tabs to the Causeway-owned clear suffix, the property replaces its interaction markup first for `validating` and again for the resulting `editing` state; the brief status flash near “Editing” confirms this lifecycle.
+The clear button is nested inside an asynchronously upgraded field adapter, so it does not exist when the property immediately attempts ordinary post-render focus restoration.
+The first replacement therefore leaves body focus active, and the second replacement has no active owned element from which to infer the original clear-button intent.
+
+## Goals / Non-Goals
+
+**Goals:**
+
+- Keep keyboard focus on Clear through both validation renders and lazy field upgrade.
+- Continue from Clear to Save on the next Tab.
+- Preserve external focus departure and avoid a focus trap.
+- Keep the existing clear, validation, cancellation, and protected-value semantics.
+
+**Non-Goals:**
+
+- Remove the visible validating/editing status transition.
+- Change validation debounce or GraphQL authority.
+- Change Save/Cancel restoration, native editor behavior, or action-prompt focus policy.
+- Introduce global focus listeners or private Vaadin shadow access.
+
+## Decisions
+
+### Store a prompt-local clear focus intent on the property
+
+The property will record clear focus when a `focusin` event identifies its Causeway clear suffix.
+A `focusin` on another owned editor or action replaces or clears that intent.
+A genuine `focusout` beyond the property clears it, while focusout caused by the property's own rendering does not.
+
+This distinguishes the temporary body-focus gap created by node replacement from intentional external navigation.
+Inferring focus only from `document.activeElement` was rejected because the second validation render observes the body.
+
+### Add an adapter-level focusClear method
+
+`<causeway-field-editor>` will expose an internal `focusClear()` method that records a request before upgrade and focuses the suffix once it is installed and visible.
+The property can therefore issue the request synchronously against replacement markup without waiting for toolkit details.
+If the field is empty or does not qualify for clearing, the request safely expires without redirecting focus elsewhere.
+
+A MutationObserver or timer in the property was rejected because it would duplicate adapter lifecycle knowledge and make focus timing nondeterministic.
+
+### Preserve intent across consecutive owned renders
+
+While the active element is temporarily the document body and clear focus intent is pending, each interaction render forwards the same request to the newest adapter.
+Once the clear button receives focus, normal focus events maintain the intent; moving to Save, Cancel, the field, or outside clears it.
+
+### Test the complete asynchronous sequence
+
+Foundation tests will cover a pre-upgrade clear-focus request, visibility gating, property intent lifecycle, consecutive validation renders, and external departure.
+Petclinic Playwright will pause on Clear long enough for validation to complete, assert that focus remains there, then Tab to Save.
+
+## Risks / Trade-offs
+
+- **Risk:** Retained intent could steal focus after genuine departure.
+ **Mitigation:** Clear it on non-rendering focusout beyond the property and on focusin to any other owned control.
+- **Risk:** An empty replacement has no clear button.
+ **Mitigation:** Focus only a visible clear suffix and discard the adapter request when upgrade completes without one.
+- **Risk:** Multiple renders can target disconnected adapters.
+ **Mitigation:** Existing generation and connection checks remain authoritative; each replacement owns only its own request.
+- **Risk:** Status flashing could be mistaken for the focus defect.
+ **Mitigation:** Keep status semantics unchanged and verify focus independently through active-element assertions.
diff --git a/openspec/changes/preserve-field-clear-focus/proposal.md b/openspec/changes/preserve-field-clear-focus/proposal.md
new file mode 100644
index 00000000000..37f1b7bc38c
--- /dev/null
+++ b/openspec/changes/preserve-field-clear-focus/proposal.md
@@ -0,0 +1,28 @@
+## Why
+
+The Causeway-owned field clear button is now tabbable, but debounced property validation replaces the editor while focus is on that button.
+Because the replacement adapter upgrades asynchronously, focus falls to the document body and the next Tab restarts at the field.
+
+## What Changes
+
+- Track clear-button focus as an owned property-interaction focus intent.
+- Carry that intent across consecutive validation rerenders while the replacement field adapter upgrades.
+- Ask the replacement adapter to focus its clear suffix once the non-empty control is ready.
+- Clear the intent when focus moves to another owned control or genuinely leaves the property.
+- Extend foundation and Petclinic regressions to hold focus on Clear through validation and continue naturally to Save.
+
+## Capabilities
+
+### New Capabilities
+
+None.
+
+### Modified Capabilities
+
+- `domain-web-components`: Extend deterministic property-editor focus preservation to asynchronously replaced owned controls.
+- `vaadin-semantic-editor-families`: Require the Causeway-owned clear suffix to retain focus across owner validation rerenders.
+
+## Impact
+
+The change affects property interaction focus bookkeeping, the internal field adapter focus API, foundation tests, and Petclinic browser qualification.
+It does not change GraphQL operations, validation timing, values, semantic events, public element names, routes, CSP, dependencies, toolkit assets, or native fallback.
diff --git a/openspec/changes/preserve-field-clear-focus/specs/domain-web-components/spec.md b/openspec/changes/preserve-field-clear-focus/specs/domain-web-components/spec.md
new file mode 100644
index 00000000000..b0f728946b6
--- /dev/null
+++ b/openspec/changes/preserve-field-clear-focus/specs/domain-web-components/spec.md
@@ -0,0 +1,25 @@
+## MODIFIED Requirements
+
+### Requirement: Accessible standard interaction presentation
+Standard property editors and the standard action prompt SHALL expose labelled controls, associated validation, pending and error announcements, deterministic focus behavior, keyboard operation, and application styling through light-DOM semantic markup.
+
+#### Scenario: Parameterized prompt opens and closes
+- **WHEN** a keyboard user opens a parameterized action prompt
+- **THEN** focus moves to the first operable prompt control
+- **AND** Escape cancels the prompt without invocation
+- **AND** focus returns to the originating action affordance
+
+#### Scenario: Invalid property value
+- **WHEN** server validation rejects a pending property value
+- **THEN** the editor associates the reason with its input and announces it accessibly
+- **AND** retains the pending value for correction or cancellation
+
+#### Scenario: Property validation replaces focused controls
+- **WHEN** a user tabs from a changed property editor to an owned Clear, Save, or Cancel control and validation-driven rendering replaces that focused control
+- **THEN** focus remains on the equivalent newly rendered control, including while an internal adapter upgrades asynchronously
+- **AND** subsequent Tab or Shift+Tab navigation continues from that control without restarting at the editor
+
+#### Scenario: Focus leaves the property during validation
+- **WHEN** focus genuinely moves beyond the property before validation rendering completes
+- **THEN** the property does not restore an obsolete internal focus intent
+- **AND** external focus remains unchanged
diff --git a/openspec/changes/preserve-field-clear-focus/specs/vaadin-semantic-editor-families/spec.md b/openspec/changes/preserve-field-clear-focus/specs/vaadin-semantic-editor-families/spec.md
new file mode 100644
index 00000000000..f12c9932e54
--- /dev/null
+++ b/openspec/changes/preserve-field-clear-focus/specs/vaadin-semantic-editor-families/spec.md
@@ -0,0 +1,41 @@
+## MODIFIED Requirements
+
+### Requirement: Causeway-owned interaction semantics
+Each field adapter SHALL map Causeway labels, descriptions, required and disabled state, validation, pending values, focus, keyboard clearing, cancellation, and semantic events into its internal control.
+It MUST NOT establish a second interaction or validation state machine.
+
+#### Scenario: User changes an editable property
+- **WHEN** an internal control emits a value change
+- **THEN** the owning Causeway property interaction parses, validates, and saves through its existing context
+- **AND** success, failure, cancellation, focus restoration, and semantic events match native behavior
+
+#### Scenario: User changes an action parameter
+- **WHEN** an internal control changes a prepared object or service action parameter
+- **THEN** the interaction controller updates that parameter through the existing argument negotiation path
+- **AND** dependent parameter preparation and submission emit only advertised arguments
+
+#### Scenario: Optional field exposes clearing
+- **WHEN** a qualified optional non-protected field has a non-empty value and presents a visible clear affordance
+- **THEN** keyboard users can reach that affordance through normal forward and reverse Tab navigation
+- **AND** its accessible name identifies the semantic field being cleared
+- **AND** keyboard or pointer activation clears through the existing Causeway pending-value path
+
+#### Scenario: Clear control survives owner rerendering
+- **WHEN** validation replaces a field adapter while its Causeway-owned clear suffix has focus
+- **THEN** the replacement adapter retains the clear-focus request until its visible suffix is ready
+- **AND** focus returns to that suffix without exposing toolkit lifecycle details to the application
+
+#### Scenario: Keyboard user clears a field
+- **WHEN** the keyboard user activates the Causeway-owned clear affordance
+- **THEN** the now-empty clear affordance is removed from the tab sequence
+- **AND** focus returns to the field without cancelling the interaction, submitting it, or exposing a second value state
+
+#### Scenario: Validation rejects a value
+- **WHEN** client codec or authoritative GraphQL validation rejects the pending value
+- **THEN** the Causeway host owns the bounded error and invalid state
+- **AND** the internal control cannot submit or display a successful-looking alternative value
+
+#### Scenario: Protected text is edited
+- **WHEN** a protected semantic editor is prepared, changed, validated, cancelled, fails, or submits
+- **THEN** its prior or pending value is absent from markup, semantic events, errors, diagnostics, operation summaries, and route evidence
+- **AND** the internal control initializes empty with appropriate password-autocomplete behavior
diff --git a/openspec/changes/preserve-field-clear-focus/tasks.md b/openspec/changes/preserve-field-clear-focus/tasks.md
new file mode 100644
index 00000000000..2cbd982700d
--- /dev/null
+++ b/openspec/changes/preserve-field-clear-focus/tasks.md
@@ -0,0 +1,27 @@
+## 1. Baseline and regressions
+
+- [ ] 1.1 Record clear-focus loss, the validation status flash, and unchanged authority/security boundaries.
+- [ ] 1.2 Extend field-widget tests for clear-focus requests before and after asynchronous upgrade.
+- [ ] 1.3 Extend property tests for clear intent across consecutive renders and genuine external departure.
+- [ ] 1.4 Extend Petclinic browser coverage to hold Clear focus through validation and continue to Save.
+
+## 2. Adapter clear-focus lifecycle
+
+- [ ] 2.1 Add an internal field-adapter method that requests clear focus before or after upgrade.
+- [ ] 2.2 Focus only a connected visible clear suffix after upgrade and safely expire inapplicable requests.
+- [ ] 2.3 Preserve generation, disconnection, protected-value, and native-fallback behavior.
+
+## 3. Property focus intent
+
+- [ ] 3.1 Track focus entering the Causeway clear suffix independently from editor and action focus.
+- [ ] 3.2 Preserve clear intent while property-owned rendering temporarily leaves body focus active.
+- [ ] 3.3 Forward clear intent to each replacement adapter across validating and editing renders.
+- [ ] 3.4 Clear intent when focus moves to another owned control or genuinely leaves the property.
+- [ ] 3.5 Preserve Save/Cancel restoration, deferred editor selection, validation, cancellation, and external focus.
+
+## 4. Qualification
+
+- [ ] 4.1 Run the complete foundation and HTMX route-policy suites.
+- [ ] 4.2 Run focused Petclinic Java integration tests.
+- [ ] 4.3 Run Petclinic Playwright under Vaadin-default and explicit-native policies.
+- [ ] 4.4 Run RAT, ordinary packaging, strict OpenSpec validation, and whitespace checks.