From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 04DD36D30E for ; Thu, 4 Feb 2021 16:12:01 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id ED30E25B28 for ; Thu, 4 Feb 2021 16:12:00 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 327C725B1A for ; Thu, 4 Feb 2021 16:12:00 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id DECC64617B for ; Thu, 4 Feb 2021 16:11:59 +0100 (CET) Message-ID: Date: Thu, 4 Feb 2021 16:11:58 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:86.0) Gecko/20100101 Thunderbird/86.0 Content-Language: en-US To: Proxmox Backup Server development discussion , Oguz Bektas References: <20210204143930.917664-1-o.bektas@proxmox.com> From: Thomas Lamprecht In-Reply-To: <20210204143930.917664-1-o.bektas@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.026 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.178 Looks like a legit reply (A) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [mozilla.org] Subject: Re: [pbs-devel] [PATCH proxmox-backup] ui: autofocus after rendering text fields for 2fa X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Feb 2021 15:12:01 -0000 On 04.02.21 15:39, Oguz Bektas wrote: > also fix a small typo > > Signed-off-by: Oguz Bektas > --- > www/LoginView.js | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/www/LoginView.js b/www/LoginView.js > index 15373533..5e8b2f93 100644 > --- a/www/LoginView.js > +++ b/www/LoginView.js > @@ -525,6 +525,11 @@ Ext.define('PBS.login.TfaWindow', { > allowBlank: false, > regex: /^[0-9]{6}$/, > regexText: 'TOTP codes consist of six decimal digits', > + listeners: { > + afterrender: function(field) { > + field.focus(); > + }, > + }, arrow functions are much nicer for such things: listeners: { afterrender: field => field.focus(), }, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions Besides that, this could be added to the existing controllers 'field' control instance, it's not really nice to have the control logic split. I did not test it, but if the following works you get +1 not +10 lines of change: diff --git a/www/LoginView.js b/www/LoginView.js index f7380339..54bc8de0 100644 --- a/www/LoginView.js +++ b/www/LoginView.js @@ -338,6 +338,7 @@ Ext.define('PBS.login.TfaWindow', { // non-visible tab, so we can just directly use the valid param this.getViewModel().set('canConfirm', valid); }, + afterrender: field => field.focus(), // ensure focus on initial render }, }, > }, > ], > }, > @@ -551,7 +556,12 @@ Ext.define('PBS.login.TfaWindow', { > reference: 'recoveryKey', > allowBlank: false, > regex: /^[0-9a-f]{4}(-[0-9a-f]{4}){3}$/, > - regexText: 'Does not looks like a valid recovery key', > + regexText: 'Does not look like a valid recovery key', we may also want to wrap that in gettext() for translation availability (separate patch please) > + listeners: { > + afterrender: function(field) { > + field.focus(); same here. > + }, > + }, > }, > { > xtype: 'box', >