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 2022/11/18 11:17:19 UTC

[myfaces-tobago] branch t5_selectMany updated: feat(selectMany): impl autofocus

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

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


The following commit(s) were added to refs/heads/t5_selectMany by this push:
     new 81ade3d227 feat(selectMany): impl autofocus
81ade3d227 is described below

commit 81ade3d22798afb14f911ea735a0884fdff598bc
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Fri Nov 18 12:17:08 2022 +0100

    feat(selectMany): impl autofocus
    
    Issue: TOBAGO-2159
---
 .../tobago/internal/renderkit/renderer/SelectManyRenderer.java     | 1 +
 .../tobago-theme-standard/src/main/ts/tobago-select-many.ts        | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyRenderer.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyRenderer.java
index ef30a8cccf..068145ff30 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyRenderer.java
@@ -146,6 +146,7 @@ public class SelectManyRenderer<T extends AbstractUISelectMany> extends SelectMa
     writer.writeAttribute(HtmlAttributes.READONLY, filter == null);
     writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
     writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
+    renderFocus(clientId, component.isFocus(), component.isError(), facesContext, writer);
 
     writer.endElement(HtmlElements.INPUT);
 
diff --git a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-select-many.ts b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-select-many.ts
index e36c68e86d..2f559e688e 100644
--- a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-select-many.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-select-many.ts
@@ -109,6 +109,11 @@ class SelectMany extends HTMLElement {
       const input = this.filterInput;
       input.addEventListener("keyup", this.filterEvent.bind(this));
     }
+
+    // handle autofocus; trigger focus event
+    if (document.activeElement.id === this.filterInput.id) {
+      this.focusEvent();
+    }
   }
 
   select(event: MouseEvent): void {
@@ -372,7 +377,7 @@ class SelectMany extends HTMLElement {
     }
   }
 
-  private focusEvent(event: FocusEvent): void {
+  private focusEvent(): void {
     if (!this.hiddenSelect.disabled) {
       if (!this.classList.contains(this.CssClass.TOBAGO_FOCUS)) {
         this.setFocus(true);