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/05/22 11:48:07 UTC

(myfaces-tobago) branch main updated (be87c321a8 -> c561864c75)

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

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


    from be87c321a8 ci(dependabot): remote NPM updates for Tobago 5
     new 9ca59c6b45 fix(dropdown): position
     new c561864c75 build(theme): rebuild

The 2 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:
 .../DropdownMenuPosition.test.js                   | 15 ++++++++
 .../DropdownMenuPosition.xhtml                     | 17 +++++++++
 .../tobago-theme-standard/src/main/js/tobago.js    |  8 ++--
 .../src/main/js/tobago.js.map                      |  2 +-
 .../src/main/ts/tobago-dropdown-menu.ts            | 43 +++++++++++++---------
 5 files changed, 63 insertions(+), 22 deletions(-)


(myfaces-tobago) 02/02: build(theme): rebuild

Posted by hn...@apache.org.
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 c561864c75cc2c1a923139145d97d8f1196cf072
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Thu May 22 13:41:05 2025 +0200

    build(theme): rebuild
---
 tobago-theme/tobago-theme-standard/src/main/js/tobago.js     | 8 ++++----
 tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

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 c0f942823e..0f3f15e824 100644
--- a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js
+++ b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js
@@ -1,19 +1,19 @@
-!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";var e,t,s,n;!function(e){e.ACTIVE="active",e.AUTOCOMPLETE="autocomplete",e.AUTOCOMPLETE_INPUT="autocomplete-input",e.BOTTOM_0="bottom-0",e.COLLAPSE="collapse",e.COLLAPSING="collapsing",e.D_NONE="d-none",e.DISABLED="disabled",e.DROPDOWN="dropdown",e.DROPDOWN_ITEM="dropdown-item",e.DROPDOWN_MENU="dropdown-menu",e.DROPDOWN_MENU_END="dropdown-menu-end",e.END_0="end-0",e.FADE="fade",e.FIXED_BOTTOM="fixe [...]
+!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";var e,t,s,n;!function(e){e.ACTIVE="active",e.AUTOCOMPLETE="autocomplete",e.AUTOCOMPLETE_INPUT="autocomplete-input",e.BOTTOM_0="bottom-0",e.COLLAPSE="collapse",e.COLLAPSING="collapsing",e.D_NONE="d-none",e.DISABLED="disabled",e.DROPDOWN="dropdown",e.DROPDOWN_ITEM="dropdown-item",e.DROPDOWN_MENU="dropdown-menu",e.DROPDOWN_MENU_END="dropdown-menu-end",e.END_0="end-0",e.FADE="fade",e.FIXED_BOTTOM="fixe [...]
 /*!
       * Bootstrap v5.3.5 (https://getbootstrap.com/)
       * Copyright 2011-2025 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
       * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
       */
-const st=new Map,nt={set(e,t,s){st.has(e)||st.set(e,new Map);const n=st.get(e);n.has(t)||0===n.size?n.set(t,s):console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(n.keys())[0]}.`)},get:(e,t)=>st.has(e)&&st.get(e).get(t)||null,remove(e,t){if(!st.has(e))return;const s=st.get(e);s.delete(t),0===s.size&&st.delete(e)}},it="transitionend",ot=e=>(e&&window.CSS&&window.CSS.escape&&(e=e.replace(/#([^\s"#']+)/g,((e,t)=>`#${CSS.escape(t)}`))),e),r [...]
+const st=new Map,nt={set(e,t,s){st.has(e)||st.set(e,new Map);const n=st.get(e);n.has(t)||0===n.size?n.set(t,s):console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(n.keys())[0]}.`)},get:(e,t)=>st.has(e)&&st.get(e).get(t)||null,remove(e,t){if(!st.has(e))return;const s=st.get(e);s.delete(t),0===s.size&&st.delete(e)}},it="transitionend",ot=e=>(e&&window.CSS&&window.CSS.escape&&(e=e.replace(/#([^\s"#']+)/g,((e,t)=>`#${CSS.escape(t)}`))),e),r [...]
 /**
      * @license
      * Copyright 2017 Google LLC
      * SPDX-License-Identifier: BSD-3-Clause
-     */const or=globalThis,rr=or.trustedTypes,ar=rr?rr.createPolicy("lit-html",{createHTML:e=>e}):void 0,lr="$lit$",dr=`lit$${Math.random().toFixed(9).slice(2)}$`,cr="?"+dr,hr=`<${cr}>`,ur=document,pr=()=>ur.createComment(""),gr=e=>null===e||"object"!=typeof e&&"function"!=typeof e,mr=Array.isArray,fr="[ \t\n\f\r]",br=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,vr=/-->/g,_r=/>/g,Er=RegExp(`>|${fr}(?:([^\\s"'>=/]+)(${fr}*=${fr}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),yr=/'/g,wr [...]
+     */const or=globalThis,rr=or.trustedTypes,ar=rr?rr.createPolicy("lit-html",{createHTML:e=>e}):void 0,lr="$lit$",dr=`lit$${Math.random().toFixed(9).slice(2)}$`,cr="?"+dr,hr=`<${cr}>`,ur=document,pr=()=>ur.createComment(""),gr=e=>null===e||"object"!=typeof e&&"function"!=typeof e,mr=Array.isArray,fr="[ \t\n\f\r]",br=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,vr=/-->/g,_r=/>/g,Er=RegExp(`>|${fr}(?:([^\\s"'>=/]+)(${fr}*=${fr}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),yr=/'/g,wr [...]
   <button type='button'
       class='tobago-button btn btn-secondary badge' aria-label='deselect ${e}'
       ${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,n=this.hiddenSelect.querySelector(`[value="${s}"]`);n.selected=!1;const i=this.badges.querySelector(`[data-tobago-value="${s}"]`),o=i.previousElementSibling,r="SPAN"===(null===(t=i.nextElementSibling)||void 0===t?void 0:t.tagName)?i.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,n=this.hiddenSelect.querySelector(`[value="${s}"]`);n.selected=!1;const i=this.badges.querySelector(`[data-tobago-value="${s}"]`),o=i.previousElementSibling,r="SPAN"===(null===(t=i.nextElementSibling)||void 0===t?void 0:t.tagName)?i.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 a685adcf07..9d16eaf970 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-key.ts","../ts/tobago-client-behaviors.ts","../ts/tobago-dropdown-menu.ts","../ts/tobago-bar.ts","../ts/tobago-date.ts","../ts/tobago-menu-store.ts","../ts/tobago-dropdown-item-factory.ts","../ts/tobago-dropdown-item.ts","../ts/tobago-dropdown.ts","../ts/tobago-overlay-type.ts","../ts/tobago-suggest-filter.ts","../ts/tobago-page-static.ts","../ts/tobago-page.ts","../ts/tobago-overlay.ts","../ts/tobago-file.ts" [...]
\ No newline at end of file
+{"version":3,"file":"tobago.js","sources":["../ts/tobago-css.ts","../ts/tobago-key.ts","../ts/tobago-client-behaviors.ts","../ts/tobago-dropdown-menu.ts","../ts/tobago-bar.ts","../ts/tobago-date.ts","../ts/tobago-menu-store.ts","../ts/tobago-dropdown-item-factory.ts","../ts/tobago-dropdown-item.ts","../ts/tobago-dropdown.ts","../ts/tobago-overlay-type.ts","../ts/tobago-suggest-filter.ts","../ts/tobago-page-static.ts","../ts/tobago-page.ts","../ts/tobago-overlay.ts","../ts/tobago-file.ts" [...]
\ No newline at end of file


(myfaces-tobago) 01/02: fix(dropdown): position

Posted by hn...@apache.org.
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 9ca59c6b45ac39bdc54089b4f3d7e056938dd4cb
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Tue May 20 09:36:08 2025 +0200

    fix(dropdown): position
    
    * add test
    * fix position if on the right
    
    Issue: TOBAGO-2422
---
 .../DropdownMenuPosition.test.js                   | 15 ++++++++
 .../DropdownMenuPosition.xhtml                     | 17 +++++++++
 .../src/main/ts/tobago-dropdown-menu.ts            | 43 +++++++++++++---------
 3 files changed, 58 insertions(+), 17 deletions(-)

diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/4200-dropdown/dropdown-menu-position/DropdownMenuPosition.test.js b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/4200-dropdown/dropdown-menu-position/DropdownMenuPosition.test.js
index 8636dffade..088ccc16d5 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/4200-dropdown/dropdown-menu-position/DropdownMenuPosition.test.js
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/4200-dropdown/dropdown-menu-position/DropdownMenuPosition.test.js
@@ -18,6 +18,21 @@
 import {elementByIdFn, innerHeight, querySelectorFn, scrollTo} from "/script/tobago-test.js";
 import {JasmineTestTool} from "/tobago/test/tobago-test-tool.js";
 
+it("Button dropdown on the right", function (done) {
+  const button = elementByIdFn("page:mainForm:buttonDropdownRight::command");
+  const dropdownMenu = querySelectorFn(".tobago-dropdown-menu[name='page:mainForm:buttonDropdownRight']");
+
+  const test = new JasmineTestTool(done);
+  test.event("click", button, () => dropdownMenu().classList.contains("show"));
+  test.waitMs(100);
+  test.do(() => expect(dropdownMenu().classList).toContain("show"));
+  test.do(() => expect(dropdownMenu().getBoundingClientRect().left).toBeGreaterThan(0));
+  test.do(() => expect(dropdownMenu().getBoundingClientRect().left).toBeLessThan(window.innerWidth));
+  test.do(() => expect(dropdownMenu().getBoundingClientRect().right).toBeGreaterThan(0));
+  test.do(() => expect(dropdownMenu().getBoundingClientRect().right).toBeLessThan(window.innerWidth));
+  test.start();
+});
+
 it("default - SelectOneList: upper half", function (done) {
   const tobagoHeader = querySelectorFn("tobago-header.sticky-top");
   const selectOneList = elementByIdFn("page:mainForm:defaultSelectOneList");
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/4200-dropdown/dropdown-menu-position/DropdownMenuPosition.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/4200-dropdown/dropdown-menu-position/DropdownMenuPosition.xhtml
index cd96042d05..a37ae1f303 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/4200-dropdown/dropdown-menu-position/DropdownMenuPosition.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/4200-dropdown/dropdown-menu-position/DropdownMenuPosition.xhtml
@@ -23,6 +23,23 @@
                 xmlns:tc="http://myfaces.apache.org/tobago/component"
                 xmlns:ui="jakarta.faces.facelets">
 
+  <tc:header>
+    <tc:style position="fixed" top="60px" left="0" width="100%" customClass="blue"/>
+    <tc:bar>
+      <f:facet name="brand">
+        BRAND
+      </f:facet>
+      CONTENT OF TC:BAR
+      <f:facet name="after">
+        <tc:button id="buttonDropdownRight" label="X" omit="true">
+          <tc:link
+              label="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."
+              omit="true"/>
+        </tc:button>
+      </f:facet>
+    </tc:bar>
+  </tc:header>
+
   <tc:panel>
     <tc:style height="1000px"/>
     This is a 1000px height panel to make sure the components for testing can be at the top of the browser window.
diff --git a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-dropdown-menu.ts b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-dropdown-menu.ts
index 905726ef8c..c799a661dc 100644
--- a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-dropdown-menu.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-dropdown-menu.ts
@@ -140,23 +140,11 @@ export class DropdownMenu {
     const refElementRect = this.referenceElement.getBoundingClientRect();
 
     //calc horizontal positioning and max-width
-    const rightBorder = this.body.offsetWidth;
-    switch (this.alignment) {
-      case DropdownMenuAlignment.start:
-      case DropdownMenuAlignment.centerFullWidth:
-        this.dropdownMenuElement.style.left = "0px";
-        this.dropdownMenuElement.style.left = (refElementRect.left - this.dropdownRect.left) + "px";
-        this.dropdownMenuElement.style.right = null;
-        this.dropdownMenuElement.style.maxWidth = rightBorder - refElementRect.left
-            - parseFloat(getComputedStyle(this.dropdownMenuElement).marginRight) + "px";
-        break;
-      case DropdownMenuAlignment.end:
-        this.dropdownMenuElement.style.left = null;
-        this.dropdownMenuElement.style.right = "0px";
-        this.dropdownMenuElement.style.right = (this.dropdownRect.right - refElementRect.right) + "px";
-        this.dropdownMenuElement.style.maxWidth = refElementRect.right
-            - parseFloat(getComputedStyle(this.dropdownMenuElement).marginLeft) + "px";
-        break;
+    this.calcHorizontalPositioningAndMaxWidth(refElementRect, this.alignment);
+    if (this.dropdownMenuElement.offsetWidth - 1 > parseInt(this.dropdownMenuElement.style.maxWidth)
+        && (window.innerWidth / 2) <= refElementRect.left + (refElementRect.right - refElementRect.left)) {
+      // Content of dropdown is too big and reference element is on the right side; do DropdownMenuAlignment.end
+      this.calcHorizontalPositioningAndMaxWidth(refElementRect, DropdownMenuAlignment.end);
     }
 
     //calc width
@@ -196,6 +184,27 @@ export class DropdownMenu {
     }
   }
 
+  private calcHorizontalPositioningAndMaxWidth(refElementRect: DOMRect, alignment: DropdownMenuAlignment): void {
+    const rightBorder = this.body.offsetWidth;
+    switch (alignment) {
+      case DropdownMenuAlignment.start:
+      case DropdownMenuAlignment.centerFullWidth:
+        this.dropdownMenuElement.style.left = "0px";
+        this.dropdownMenuElement.style.left = (refElementRect.left - this.dropdownRect.left) + "px";
+        this.dropdownMenuElement.style.right = null;
+        this.dropdownMenuElement.style.maxWidth = rightBorder - refElementRect.left
+            - parseFloat(getComputedStyle(this.dropdownMenuElement).marginRight) + "px";
+        break;
+      case DropdownMenuAlignment.end:
+        this.dropdownMenuElement.style.left = null;
+        this.dropdownMenuElement.style.right = "0px";
+        this.dropdownMenuElement.style.right = (this.dropdownRect.right - refElementRect.right) + "px";
+        this.dropdownMenuElement.style.maxWidth = refElementRect.right
+            - parseFloat(getComputedStyle(this.dropdownMenuElement).marginLeft) + "px";
+        break;
+    }
+  }
+
   private get body(): HTMLElement {
     const root = document.getRootNode() as ShadowRoot | Document;
     return root.querySelector("body");