Text Field Loses Focus

I have various pages where I have implemented the focus method on the first text field (tried $w.onReady as well as the text field viewportEnter events). When loading these pages first time it works, but whenever the pages load via a link from another page, the field loses focus after a second or so. Does anyone have a fix for this?

Here is a very simple example to demonstrate the issue. If you go to
https://astutesystems.wixsite.com/testsite/test-focus
You will see that Field 1 is correctly given focus when the page loads:

Now go to https://astutesystems.wixsite.com/testsite and click on the ‘Register’ button which is a simple link to the first page. It focuses correctly for about a second and then loses focus… highlighting the field in red because it’s set to mandatory:

My only solution so far is to do the focus on a setTimeout of about two seconds but that really isn’t a sensible option. If anyone has an alternative fix for this I’d like to hear about it!

1 Like

Can you post your code?

@jonatandor35 here you go - it’s extremely simple. The results are the same whether using the onReady function or viewportEnter.

$w.onReady(function () {
    $w('#txtField1').focus();
});

If handled via the viewportEnter function:

export function txtField1_viewportEnter(event) {
    $w('#txtField1').focus();
}

So I don’t know. Maybe someone else?

I tried resetValidityIndication() and couldn’t get this to focus without indicating a validity problem. Seems strange to me.

I’m going to pass this on to QA for evaluation.

A ticket has been opened for this issue.

Thanks - please let me know if/when it gets checked

Hi all! I got the same issue! Is there any update on it?
Thanks!

Same issue here… Any update?
Thanks in advance.

Same issue here, what is the ticket number? can we vote on it?

1 Like

I am having a seemingly similar issue where .focus(); doesn’t seem to work on ANY input field, whether loaded at the start via .onReady(); or within a function. It seems the entire .focus(); call is just broken. Any update on the ticket that was submitted 10+ months ago? It IS an accessibility feature, after all!

Hi There! Same problem here! Any news or workaround? thanks.

Hi @peteleyland ,

Issue has been fixed, please check on your end.

Thanks.