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/06/19 14:14:33 UTC
(myfaces-tobago) branch main updated: fix(demo): sidebar navigation
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
The following commit(s) were added to refs/heads/main by this push:
new 360176874f fix(demo): sidebar navigation
360176874f is described below
commit 360176874f525dd52f96ffe5d4b6c6a401d5da1d
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Thu Jun 19 16:12:52 2025 +0200
fix(demo): sidebar navigation
fix: Uncaught TypeError: Cannot read properties of null (reading 'scrollIntoView')
---
tobago-example/tobago-example-demo/src/main/ts/demo-sidebar.ts | 6 ++++--
.../tobago-example-demo/src/main/webapp/js/demo-sidebar.js | 6 ++++--
.../tobago-example-demo/src/main/webapp/js/demo-sidebar.js.map | 2 +-
tobago-example/tobago-example-demo/src/main/webapp/js/demo.js | 6 ++++--
tobago-example/tobago-example-demo/src/main/webapp/js/demo.js.map | 2 +-
5 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/tobago-example/tobago-example-demo/src/main/ts/demo-sidebar.ts b/tobago-example/tobago-example-demo/src/main/ts/demo-sidebar.ts
index fc7fb508bb..b48bc54933 100644
--- a/tobago-example/tobago-example-demo/src/main/ts/demo-sidebar.ts
+++ b/tobago-example/tobago-example-demo/src/main/ts/demo-sidebar.ts
@@ -158,8 +158,10 @@ export class Sidebar extends HTMLElement {
private updateTableOfContentsScrollPosition(): void {
const activeNavLinks = this.activeNavLinks;
- const centerIndex = Math.floor(activeNavLinks.length / 2);
- activeNavLinks.item(centerIndex).scrollIntoView({block: "center", behavior: "smooth"});
+ if (activeNavLinks.length > 0) {
+ const centerIndex = Math.floor(activeNavLinks.length / 2);
+ activeNavLinks.item(centerIndex).scrollIntoView({block: "center", behavior: "smooth"});
+ }
}
private updateLeft(): void {
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/js/demo-sidebar.js b/tobago-example/tobago-example-demo/src/main/webapp/js/demo-sidebar.js
index 20dd475f4d..08c697e712 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/js/demo-sidebar.js
+++ b/tobago-example/tobago-example-demo/src/main/webapp/js/demo-sidebar.js
@@ -128,8 +128,10 @@ export class Sidebar extends HTMLElement {
}
updateTableOfContentsScrollPosition() {
const activeNavLinks = this.activeNavLinks;
- const centerIndex = Math.floor(activeNavLinks.length / 2);
- activeNavLinks.item(centerIndex).scrollIntoView({ block: "center", behavior: "smooth" });
+ if (activeNavLinks.length > 0) {
+ const centerIndex = Math.floor(activeNavLinks.length / 2);
+ activeNavLinks.item(centerIndex).scrollIntoView({ block: "center", behavior: "smooth" });
+ }
}
updateLeft() {
this.style.left = this.parentElement.getBoundingClientRect().left + "px";
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/js/demo-sidebar.js.map b/tobago-example/tobago-example-demo/src/main/webapp/js/demo-sidebar.js.map
index f1b65624aa..dda50a8663 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/js/demo-sidebar.js.map
+++ b/tobago-example/tobago-example-demo/src/main/webapp/js/demo-sidebar.js.map
@@ -1 +1 @@
-{"version":3,"file":"demo-sidebar.js","sourceRoot":"","sources":["../../ts/demo-sidebar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,MAAM,OAAO,OAAQ,SAAQ,WAAW;IAKtC,iBAAiB;QACf,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,kBAAkB,CAAC,YAAY,EAAE,+DAA+D,CAAC,CAAC;QAEvG,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,GAAG,EAAE;gBAC7C,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC;gBACnD,MAAM,kBAAkB,GAAG,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC,CAAC;gBAC [...]
\ No newline at end of file
+{"version":3,"file":"demo-sidebar.js","sourceRoot":"","sources":["../../ts/demo-sidebar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,MAAM,OAAO,OAAQ,SAAQ,WAAW;IAKtC,iBAAiB;QACf,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,kBAAkB,CAAC,YAAY,EAAE,+DAA+D,CAAC,CAAC;QAEvG,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,GAAG,EAAE;gBAC7C,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC;gBACnD,MAAM,kBAAkB,GAAG,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC,CAAC;gBAC [...]
\ No newline at end of file
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/js/demo.js b/tobago-example/tobago-example-demo/src/main/webapp/js/demo.js
index e37f542d24..83482cf738 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/js/demo.js
+++ b/tobago-example/tobago-example-demo/src/main/webapp/js/demo.js
@@ -462,8 +462,10 @@
}
updateTableOfContentsScrollPosition() {
const activeNavLinks = this.activeNavLinks;
- const centerIndex = Math.floor(activeNavLinks.length / 2);
- activeNavLinks.item(centerIndex).scrollIntoView({ block: "center", behavior: "smooth" });
+ if (activeNavLinks.length > 0) {
+ const centerIndex = Math.floor(activeNavLinks.length / 2);
+ activeNavLinks.item(centerIndex).scrollIntoView({ block: "center", behavior: "smooth" });
+ }
}
updateLeft() {
this.style.left = this.parentElement.getBoundingClientRect().left + "px";
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/js/demo.js.map b/tobago-example/tobago-example-demo/src/main/webapp/js/demo.js.map
index dae42a011f..4ffbca73d8 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/js/demo.js.map
+++ b/tobago-example/tobago-example-demo/src/main/webapp/js/demo.js.map
@@ -1 +1 @@
-{"version":3,"file":"demo.js","sources":["demo-alert.js","demo-copy-to-clipboard.js","demo-date.js","demo-highlight.js","demo-inspect.js","demo-login.js","demo-sidebar.js","demo-test.js"],"sourcesContent":["/*\n * Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to You under the Apache License, V [...]
\ No newline at end of file
+{"version":3,"file":"demo.js","sources":["demo-alert.js","demo-copy-to-clipboard.js","demo-date.js","demo-highlight.js","demo-inspect.js","demo-login.js","demo-sidebar.js","demo-test.js"],"sourcesContent":["/*\n * Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to You under the Apache License, V [...]
\ No newline at end of file