You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2020/07/02 09:55:21 UTC

[myfaces-tobago] 02/02: id is missing in boolean-checkbox inside of a dropdown

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

lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git

commit 62bf977a23a8b86e82d551faff3a5c16851e392b
Author: Udo Schnurpfeil <ud...@irian.eu>
AuthorDate: Thu Jul 2 11:55:01 2020 +0200

    id is missing in boolean-checkbox inside of a dropdown
    
    issue: TOBAGO-1633: TS refactoring
---
 .../renderkit/renderer/SelectBooleanCheckboxRenderer.java     |  1 +
 .../src/main/npm/ts/tobago-select-boolean-checkbox.ts         | 11 ++++++-----
 .../src/main/npm/ts/tobago-select-one-choice.ts               |  3 ++-
 .../src/main/npm/ts/tobago-select-one-listbox.ts              |  3 ++-
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectBooleanCheckboxRenderer.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectBooleanCheckboxRenderer.java
index eea13da..aee06bf 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectBooleanCheckboxRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectBooleanCheckboxRenderer.java
@@ -88,6 +88,7 @@ public class SelectBooleanCheckboxRenderer extends MessageLayoutRendererBase {
     final Markup markup = select.getMarkup();
 
     writer.startElement(getOuterHtmlTag());
+    writer.writeIdAttribute(clientId);
     writer.writeClassAttribute(
         getTobagoClass(),
         getTobagoClass().createMarkup(markup),
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-select-boolean-checkbox.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-select-boolean-checkbox.ts
index a6a3593..88712d6 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-select-boolean-checkbox.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-select-boolean-checkbox.ts
@@ -25,10 +25,10 @@ export class SelectBooleanCheckbox extends HTMLElement {
   }
 
   connectedCallback(): void {
-    this.input.addEventListener("focus", Focus.setLastFocusId);
+    this.field.addEventListener("focus", Focus.setLastFocusId);
 
-    if (this.input.readOnly) {
-      this.input.addEventListener("click", preventClick);
+    if (this.field.readOnly) {
+      this.field.addEventListener("click", preventClick);
     }
 
     function preventClick(event: MouseEvent): void {
@@ -37,8 +37,9 @@ export class SelectBooleanCheckbox extends HTMLElement {
     }
   }
 
-  get input(): HTMLInputElement {
-    return this.querySelector(DomUtils.escapeClientId(this.id + DomUtils.SUB_COMPONENT_SEP + "field"));
+  get field(): HTMLInputElement {
+    const rootNode = this.getRootNode() as ShadowRoot | Document;
+    return rootNode.getElementById(this.id + DomUtils.SUB_COMPONENT_SEP + "field") as HTMLInputElement;
   }
 }
 
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-select-one-choice.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-select-one-choice.ts
index fff94da..9591482 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-select-one-choice.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-select-one-choice.ts
@@ -28,7 +28,8 @@ class SelectOneChoice extends HTMLElement {
   }
 
   get field(): HTMLInputElement {
-    return this.querySelector(DomUtils.escapeClientId(this.id + DomUtils.SUB_COMPONENT_SEP + "field"));
+    const rootNode = this.getRootNode() as ShadowRoot | Document;
+    return rootNode.getElementById(this.id + DomUtils.SUB_COMPONENT_SEP + "field") as HTMLInputElement;
   }
 }
 
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-select-one-listbox.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-select-one-listbox.ts
index 8b3eac8..35dd414 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-select-one-listbox.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-select-one-listbox.ts
@@ -28,7 +28,8 @@ export class SelectOneListbox extends HTMLElement {
   }
 
   get field(): HTMLInputElement {
-    return this.querySelector(DomUtils.escapeClientId(this.id + DomUtils.SUB_COMPONENT_SEP + "field"));
+    const rootNode = this.getRootNode() as ShadowRoot | Document;
+    return rootNode.getElementById(this.id + DomUtils.SUB_COMPONENT_SEP + "field") as HTMLInputElement;
   }
 }