Tab order gets hosed on portals with requestFocus

I have a form with a portal on it to a list-type database.

If I click in the first field of the portal and hit tab, it steps through the fields horizontally as I would expect. If there are already multiple rows in the portal, it steps down to the next row after the last field as I would expect.

However, I have a button just above the portal for adding a new row to it. I am trying to make it so when you add a new row, it automatically selects the new record and activates the first field so the user doesn’t have to go and click in it himself:

forms.Library.assets_to_asset_lineitems.newRecord(false);
elements.asset_lineitem_title.requestFocus();

This works - sort of. It adds the row and selects the first field in the new row. But when I enter something and press tab, typically the cursor jumps up into the first field of the first row instead of the second field of the new row.

Occasionally, perhaps the first time I run Servoy, I will hit tab and it will go nowhere - IE staying in the same field - and then a subsequent tab will jump up into the second field of the first row.

So question is, should I be doing something different in my method? Do I need to specifically address the new portal row somehow?

While searching for other similar episodes I came across yours and noticed no one has responded. There do seem to be issues with ‘requestFocus’ in both 3.1 and 3.5 although there are some rather simple workarounds involving one more line of code until it is addressed. For reference you might want to go the this URL:

Hey John thanks for the reply. I had not come across that message - I guess my Search-Fu needs refinement :slight_smile:

However this doesn’t appear to fix the problem I am chasing - though they do still seem possibly related in a general requestFocus-being-broken sort of way.

I tried some of the various code changes but still couldn’t get a proper or consistent result; I don’t know if it’s different because in my case I am trying to reqestFocus to a field in a portal; it’s not a listview form in a tab panel like Michael Mooney’s case. As such the fields in the portal have no tab order of their own (they all show up as 0) and I’m depending on Servoy’s built-in behavior of tabbing through the fields horizontally. My initial requestFocus() seems to succeed, activating the field I ask for on the new record created in the portal, but it’s subsequent tabbing that goes crazy.

Are your focus issues creating a new record in a ‘plain’ form?