You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by hn...@apache.org on 2025/01/16 08:52:51 UTC

(myfaces-tobago) 01/02: fix(sheet): sheet-in-sheet

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

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

commit 1bd812c7fbf80d2bd7c73836a6d9ef2df22b7926
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Thu Jan 16 09:42:05 2025 +0100

    fix(sheet): sheet-in-sheet
    
    * use precise selectors
    * Resizing columns in a nested sheet doesn't resize the column of the parent sheet
    
    Issue: TOBAGO-2381
---
 .../src/main/ts/tobago-sheet.ts                    | 23 ++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-sheet.ts b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-sheet.ts
index 1436b228f6..083a191304 100644
--- a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-sheet.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-sheet.ts
@@ -181,7 +181,7 @@ export class Sheet extends HTMLElement {
 
     // resize column: mouse events -------------------------------------------------------------------------------- //
 
-    for (const resizeElement of this.querySelectorAll(".tobago-resize")) {
+    for (const resizeElement of this.querySelectorAll(":scope > header > table > thead > tr > th > .tobago-resize")) {
       resizeElement.addEventListener("click", function (): boolean {
         return false;
       });
@@ -824,7 +824,8 @@ Type: ${data.type}`);
   }
 
   private get hiddenInputScrollPosition(): HTMLInputElement {
-    return this.querySelector("input[id$='::scrollPosition']");
+    const rootNode = this.getRootNode() as ShadowRoot | Document;
+    return rootNode.getElementById(this.id + "::scrollPosition") as HTMLInputElement;
   }
 
   public get selectable(): Selectable {
@@ -853,7 +854,8 @@ Type: ${data.type}`);
   }
 
   private get hiddenInputSelected(): HTMLInputElement {
-    return this.querySelector("input[id$='::selected']");
+    const rootNode = this.getRootNode() as ShadowRoot | Document;
+    return rootNode.getElementById(this.id + "::selected") as HTMLInputElement;
   }
 
   get hiddenExpanded(): HTMLInputElement {
@@ -890,7 +892,8 @@ Type: ${data.type}`);
   }
 
   private get hiddenInputLazyScrollPosition(): HTMLInputElement {
-    return this.querySelector("input[id$='::lazyScrollPosition']");
+    const rootNode = this.getRootNode() as ShadowRoot | Document;
+    return rootNode.getElementById(this.id + "::lazyScrollPosition") as HTMLInputElement;
   }
 
   get lazyRows(): number {
@@ -918,27 +921,27 @@ Type: ${data.type}`);
   }
 
   get header(): HTMLElement {
-    return this.querySelector("tobago-sheet>header");
+    return this.querySelector(":scope > header");
   }
 
   get headerCols(): NodeListOf<HTMLElement> {
-    return this.querySelectorAll("tobago-sheet>header>table>colgroup>col");
+    return this.querySelectorAll(":scope > header > table > colgroup > col");
   }
 
   get body(): HTMLElement {
-    return this.querySelector("tobago-sheet>.tobago-body");
+    return this.querySelector(":scope > .tobago-body");
   }
 
   get bodyTable(): HTMLElement {
-    return this.querySelector("tobago-sheet>.tobago-body>table");
+    return this.querySelector(":scope > .tobago-body > table");
   }
 
   get tableBody(): HTMLTableSectionElement {
-    return this.querySelector(".tobago-body tbody");
+    return this.body.querySelector(":scope > tbody");
   }
 
   get bodyCols(): NodeListOf<HTMLElement> {
-    return this.querySelectorAll("tobago-sheet>.tobago-body>table>colgroup>col");
+    return this.bodyTable.querySelectorAll(":scope > colgroup > col");
   }
 
   get rowElements(): NodeListOf<HTMLTableRowElement> {