Table with Datasource and search bar loses focus

I have this code in the SearchChanged event of an ios table with a datasource.

The problem is the search bar loses the focus with every character typed, and you have to tap it twice just to enter the first character.

is there a way to set the focus back to the search bar in the table from the SearchChanged event?


Var n As Integer = System.FontCount - 1

Var newFonts() As String
Var fontName As String

For i As Integer = 0 To n
  fontName = System.FontAt(i)
  If value = "" Then
    If fontName.IndexOf(value) <> -1 Then newFonts.add(fontName)
  End If

listFonts.thefonts = newFonts
Me.DataSource = listFonts

I think setting the Table’s datasource forces a full refresh of the control.

Replace the last line with

1 Like

Unfortunately it does the same thing with Me.ReloadDatasource

I also tried installing it on my iPhone, and it still does the same you can only type one letter at a time before having to select the search bar again.

I don’t know what it was, but I pasted the table in again (from another app) and this time the search bar works properly.

Today it’s not working again. I’ve narrowed it down to two things causing it.

If I use SelectRow or ScrollToRow, the search bar loses focus after typing a character or two.

Table1.SelectRow(0, fontRow)
Table1.ScrollToRow(0, fontRow, False, iOSMobileTable.ScrollPositions.Top)

If you don’t use the above code, the search bar works fine.

Example project here: Search Bar loses focus when typing

When the app starts, it scrolls to and selects the font Helvetica in the table. When you try typing in the search bar, you can only type one or two characters.

IMO, Losing the focus with SelectRow is to be expected. It selects the row and changes the focus to the table.

The row is scrolled to and selected long before you even select the search bar, let alone start typing in the search bar.

The row is only selected when the screen is opened, not when searching.

I turned off the Table’s built-in Search bar, and added a search bar from iOSKit.

Still broken.

Instead of using declares and code, I tried the UISearchBar from iOSkit.

I now have a working custom search bar for my table with a Datasource that displays fonts. It’s a workaround until Xojo fixes the broken Datasource table search bar.

Did you open an issue for this?

I did open an issue -

If you’re using a table where you add rows, instead of using a Datasource, the search bar works the way it should.