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 2024/10/16 09:08:06 UTC

(myfaces-tobago) 02/02: fix(lazy-sheet): empty

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 b05bb5ccc80b752259bd169bca792b3037ea0355
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Wed Oct 16 10:32:56 2024 +0200

    fix(lazy-sheet): empty
    
    * add test site
    * fix NPE
    * rebuild theme
    
    Issue: TOBAGO-2362
---
 .../86-empty-lazy/Empty_lazy_sheet.xhtml           | 42 ++++++++++++++++++++++
 .../tobago-theme-standard/src/main/js/tobago.js    |  2 +-
 .../src/main/js/tobago.js.map                      |  2 +-
 .../src/main/ts/tobago-sheet.ts                    | 10 ++++--
 4 files changed, 51 insertions(+), 5 deletions(-)

diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/86-empty-lazy/Empty_lazy_sheet.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/86-empty-lazy/Empty_lazy_sheet.xhtml
new file mode 100644
index 0000000000..6e0281d2c7
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/86-empty-lazy/Empty_lazy_sheet.xhtml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<ui:composition template="/main.xhtml"
+                xmlns="http://www.w3.org/1999/xhtml"
+                xmlns:tc="http://myfaces.apache.org/tobago/component"
+                xmlns:ui="jakarta.faces.facelets">
+  <tc:sheet id="default" value="#{sheetController.emptyList}" var="object" rows="4" lazy="true">
+    <tc:style maxHeight="500px"/>
+    <tc:column label="Name">
+      <tc:out value="#{object.name}" labelLayout="skip"/>
+    </tc:column>
+    <tc:column label="Orbit">
+      <tc:out value="#{object.orbit}" labelLayout="skip"/>
+    </tc:column>
+    <tc:column label="Period (Days)">
+      <tc:out value="#{object.period}" labelLayout="skip"/>
+    </tc:column>
+    <tc:column label="Discoverer">
+      <tc:out value="#{object.discoverer}" labelLayout="skip"/>
+    </tc:column>
+    <tc:column label="Year">
+      <tc:out value="#{object.discoverYear}" labelLayout="skip"/>
+    </tc:column>
+  </tc:sheet>
+</ui:composition>
diff --git a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js
index 8ed77bf062..7a6e2ee8cf 100644
--- a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js
+++ b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js
@@ -15,5 +15,5 @@ const $e=new Map,Pe={set(e,t,s){$e.has(e)||$e.set(e,new Map);const i=$e.get(e);i
       ${s>0?" tabindex='"+String(s)+"'":""}
       @click="${this.removeBadge.bind(this)}"
       @focus="${this.focusEvent.bind(this)}"
-      @blur="${this.blurEvent.bind(this)}"><i class='bi-x-lg'></i></button>`}removeBadge(e){var t;const s=e.target.closest(".btn-group").dataset.tobagoValue,i=this.hiddenSelect.querySelector(`[value="${s}"]`);i.selected=!1;const n=this.badges.querySelector(`[data-tobago-value="${s}"]`),o=n.previousElementSibling,r="SPAN"===(null===(t=n.nextElementSibling)||void 0===t?void 0:t.tagName)?n.nextElementSibling:null;o?o.querySelector("button.btn.badge").focus():r?r.querySelector("button.btn.ba [...]
+      @blur="${this.blurEvent.bind(this)}"><i class='bi-x-lg'></i></button>`}removeBadge(e){var t;const s=e.target.closest(".btn-group").dataset.tobagoValue,i=this.hiddenSelect.querySelector(`[value="${s}"]`);i.selected=!1;const n=this.badges.querySelector(`[data-tobago-value="${s}"]`),o=n.previousElementSibling,r="SPAN"===(null===(t=n.nextElementSibling)||void 0===t?void 0:t.tagName)?n.nextElementSibling:null;o?o.querySelector("button.btn.badge").focus():r?r.querySelector("button.btn.ba [...]
 //# sourceMappingURL=tobago.js.map
diff --git a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map
index dc0b626c55..9081da5f08 100644
--- a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map
+++ b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map
@@ -1 +1 @@
-{"version":3,"file":"tobago.js","sources":["../ts/tobago-css.ts","../ts/tobago-collapse-operation.ts","../ts/tobago-bar.ts","../../../../node_modules/@popperjs/core/lib/enums.js","../../../../node_modules/@popperjs/core/lib/dom-utils/getNodeName.js","../../../../node_modules/@popperjs/core/lib/dom-utils/getWindow.js","../../../../node_modules/@popperjs/core/lib/dom-utils/instanceOf.js","../../../../node_modules/@popperjs/core/lib/modifiers/applyStyles.js","../../../../node_modules/@poppe [...]
\ No newline at end of file
+{"version":3,"file":"tobago.js","sources":["../ts/tobago-css.ts","../ts/tobago-collapse-operation.ts","../ts/tobago-bar.ts","../../../../node_modules/@popperjs/core/lib/enums.js","../../../../node_modules/@popperjs/core/lib/dom-utils/getNodeName.js","../../../../node_modules/@popperjs/core/lib/dom-utils/getWindow.js","../../../../node_modules/@popperjs/core/lib/dom-utils/instanceOf.js","../../../../node_modules/@popperjs/core/lib/modifiers/applyStyles.js","../../../../node_modules/@poppe [...]
\ No newline at end of file
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 c239d9552e..6db052a668 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
@@ -232,8 +232,10 @@ export class Sheet extends HTMLElement {
       const lazyScrollPosition = this.lazyScrollPosition;
       const firstVisibleRow
           = this.tableBody.querySelector<HTMLTableRowElement>(`tr[row-index='${lazyScrollPosition[0]}']`);
-      this.sheetBody.scrollTop
-          = firstVisibleRow.offsetTop + lazyScrollPosition[1]; //triggers scroll event -> lazyCheck()
+      if (firstVisibleRow) {
+        this.sheetBody.scrollTop
+            = firstVisibleRow.offsetTop + lazyScrollPosition[1]; //triggers scroll event -> lazyCheck()
+      }
     }
 
     // init paging by pages ---------------------------------------------------------------------------------------- //
@@ -553,7 +555,9 @@ export class Sheet extends HTMLElement {
       const lazyScrollPosition = this.lazyScrollPosition;
       const firstRow
           = this.tableBody.querySelector<HTMLTableRowElement>(`tr[row-index='${lazyScrollPosition[0]}']`);
-      this.sheetBody.scrollTop = firstRow.offsetTop + lazyScrollPosition[1];
+      if (firstRow) {
+        this.sheetBody.scrollTop = firstRow.offsetTop + lazyScrollPosition[1];
+      }
 
       this.lazyActive = false;
     }