Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to prevent field focus from being set on the 'Go to' search at the top of a table list view

Joe Dames
Tera Expert

Does anyone know how to prevent field focus from being set on the 'Go to' search at the top of a table list view (as found on a page like /incident_list.do)? Release version   is Helsinki.

field_focus_table_list_view.png

The focus being set is causing usability issues for client with field service workers using tablet devices because when they pull up a list, the focus is set in the search field which then summons the tablet keyboard interface thereby blocking the records in the list.

The offending 'Go to' Search html element is:

<input style="width: 150px;" placeholder="Search" class="form-control" name="d49f048c0ffba20051729bd692050e5e_text"
id="d49f048c0ffba20051729bd692050e5e_text">

Things I've tried:

1. Blurring the element to take away its focus via a Client Script:

function onLoad() {

setTimeout("var reblur = document.getElementById('3e57fbf70feba20051729bd692050e36_text');reblur.blur();",5);

}

This didn't work; remembered Client Scripts do not work on table list views.

2. Set system property 'glide.ui.focus_first_element' to false, but this only stops first element focus on the form view; didn't work.

Any pointers or ideas would be much appreciated; thank you!

1 ACCEPTED SOLUTION

Joe Dames
Tera Expert

A UI Script to blur any initial focus 100% solved the described issue.



addLateLoadEvent( function() {


      document.activeElement.blur();


});



Note: This will stop ALL initial focus on EVERY page in the instance so you may want to put conditions on this.


View solution in original post

3 REPLIES 3

Bob
Giga Contributor

I did this in a record producer so that it would focus the field I wanted:



function onLoad() {


//Force focus on a field


setTimeout("var refocus = g_form.getElement('<field name here>');refocus.focus();",0);


}  



Hope this is helpful!


I tried something similar, but Client Scripts don't work on table list views.



Edit: BTW, that does work on a form to set the focus on a different field, but it does not work on the table list view. Thanks for the tip!


Joe Dames
Tera Expert

A UI Script to blur any initial focus 100% solved the described issue.



addLateLoadEvent( function() {


      document.activeElement.blur();


});



Note: This will stop ALL initial focus on EVERY page in the instance so you may want to put conditions on this.