You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2023/04/21 09:12:22 UTC

[myfaces-tobago] 01/02: fix(selectOneList): show itemLabel for selected Value issue: TOBAGO-2212

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

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

commit 5b0a1cb6f434296416ef6f5a49660cfe31ae2d47
Author: Bernd Bohmann <bo...@apache.org>
AuthorDate: Thu Apr 20 21:23:09 2023 +0200

    fix(selectOneList): show itemLabel for selected Value
    issue: TOBAGO-2212
---
 tobago-theme/tobago-theme-standard/src/main/js/tobago.js      |  2 +-
 tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map  |  2 +-
 .../src/main/ts/tobago-select-one-list.ts                     | 11 ++++++++---
 3 files changed, 10 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 026e4cf3f3..ee3f961f97 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 Be="transitionend",Me=e=>{let t=e.getAttribute("data-bs-target");if(!t||"#
       ${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){const t=e.target.closest(".btn-group").dataset.tobagoValue,s=this.hiddenSelect.querySelector(`[value="${t}"]`);s.selected=!1;const i=this.selectField.querySelector(`[data-tobago-value="${t}"]`),n=i.previousElementSibling,o="SPAN"===i.nextElementSibling.tagName?i.nextElementSibling:null;n?n.querySelector("button.btn.badge").focus():o?o.querySelector("button.btn.badge").focus():(this.filterInput.dis [...]
+      @blur="${this.blurEvent.bind(this)}"><i class='bi-x-lg'></i></button>`}removeBadge(e){const t=e.target.closest(".btn-group").dataset.tobagoValue,s=this.hiddenSelect.querySelector(`[value="${t}"]`);s.selected=!1;const i=this.selectField.querySelector(`[data-tobago-value="${t}"]`),n=i.previousElementSibling,o="SPAN"===i.nextElementSibling.tagName?i.nextElementSibling:null;n?n.querySelector("button.btn.badge").focus():o?o.querySelector("button.btn.badge").focus():(this.filterInput.dis [...]
 //# 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 256760ebce..6dfcee1786 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-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/@popperjs/core/lib/utils/getBasePlacement.j [...]
\ No newline at end of file
+{"version":3,"file":"tobago.js","sources":["../ts/tobago-css.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/@popperjs/core/lib/utils/getBasePlacement.j [...]
\ No newline at end of file
diff --git a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-select-one-list.ts b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-select-one-list.ts
index 29302f8765..1302d5aca7 100644
--- a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-select-one-list.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-select-one-list.ts
@@ -32,6 +32,11 @@ class SelectOneList extends SelectListBase {
     this.selectField.querySelector("span").textContent = text;
   }
 
+  get selectedOption() :HTMLOptionElement {
+    const value = this.hiddenSelect.value;
+    return this.hiddenSelect.querySelector(`[value="${value}"]`);
+  }
+
   connectedCallback(): void {
     super.connectedCallback();
     this.selectField.addEventListener("keydown", this.keydownEvent.bind(this));
@@ -58,7 +63,7 @@ class SelectOneList extends SelectListBase {
   private keydownEvent(event: KeyboardEvent) {
     switch (event.key) {
       case Key.ESCAPE:
-        this.spanText = this.hiddenSelect.value;
+        this.spanText = this.selectedOption.textContent;
         break;
       case Key.BACKSPACE:
         if (this.filterInput.value.length === 0) {
@@ -83,7 +88,7 @@ class SelectOneList extends SelectListBase {
   private sync() {
     this.rows.forEach((row) => {
       if (row.dataset.tobagoValue === this.hiddenSelect.value) {
-        this.spanText = this.hiddenSelect.value;
+        this.spanText = this.selectedOption.textContent;
         row.classList.add(Css.TABLE_PRIMARY); // highlight list row
       } else {
         row.classList.remove(Css.TABLE_PRIMARY); // remove highlight list row
@@ -95,7 +100,7 @@ class SelectOneList extends SelectListBase {
     this.focused = false;
     this.filterInput.value = null;
     this.filterInput.dispatchEvent(new Event("input"));
-    this.spanText = this.hiddenSelect.value;
+    this.spanText = this.selectedOption.textContent;
     this.hideDropdown();
   }
 }