Text field stops working unexpectedly

Hello folks,

I'm editing this with the simplest setup I found to replicate the issue.

Drop a text field and a table in a view.
Copy the table's default data to a custom property.
Now structure-bind the table's prop.data property to both the text field prop.text and the custom property holding the data.
Add a script transform with this:

return filter(
	lambda item: value.filter_text in item['city'],
	value.data
)

Where value.data is the data from the custom property and value.filter_text is the text field's value.
Run the preview, and type things in the text field. You'll see the table being updated, with entries that don't match filtered out.
So far so good, everything works just fine.

Now add columns to the props.columns property of the table.
If you try again now, it still works just fine.
Now set the field property of a column to city.
If you try now, typing things in the text field filters rows out of the table. When the table is empty because nothing matches anymore, the text field just stops working. It still has focus, but typing doesn't do anything.
Note that whatever column you "name", the same thing happen. You could be filtering on 'city' but only name the 'country' column, it still boinks up.

Note also that this issue appears to be chromium related, as it doesn't happen with Firefox... But Brave, Chrome and Edge all had that behavior.

Below is the original post, I'll leave it there just in case.


I'm having a bit of an issue with the text field. It loses focus when I don't want it to.
I suspect it happens when bindings on other components are evaluated.

Some context:
I'm building a dynamic search thingie to filter a table.
For each filterable column, there's a filter field.

Let's say I have a column name, and a filter field for that column. Typing things in that field will filter out any row where the value in the column name doesn't contain what's in the filter.

This works well, but when the table is updated because I typed a new character that triggers a filter, the text field loses focus.
NOTE: This only happens when ADDING a character, not deleting one.

Let's see with pictures:


Text field has focus.

image
Nothing changed in the table, text field still has focus.

image
Added a 5, my row was filtered out, text field lost focus (despite still having the blue border, which would suggest it's still selected)

image
deleted 5, row came back in the table, text field still has focus.

It makes it very unpleasant to use... Any way I can work around this ?
I have another version of this that requires a button click to apply the filters, just in case I can't solve this reliably, but I'd rather have the auto-update.

edit: I just realized I might have been on the sparse side concerning details.

So here's what goes on:

  • The filter fields are in a flex repeater.The repeated view has an output parameter called 'value', and a parameter called 'field_name' that corresponds to the column name.
  • The table's data property has a structure binding, that takes the base data and the filters
  • The base data is a list of objects, not a dataset, because it's itself built through a transform putting together several tables.
  • The binding has a script transform that filters things out of the data based on the filters.
    In case it's relevant, or someone has a better method for this, here's the transform.
from java.util import ArrayList

def check_filter(item, f):
	if isinstance(f.value, (ArrayList, list)):
		return any(str(item[f.field_name]) == str(elem) for elem in f.value)
	else:
		return str(f.value) in str(item[f.field_name]) 

return filter(
	lambda item: all(check_filter(item, f) for f in value.filters),
	value.data
)

Version is 8.1.17 and that cannot change.

edit 2:
Actually, it doesn't lose focus. Adding some logging on the onBlur event reveals that the focus is not lost. The text field just stops text fielding until it's clicked again...

1 Like

I guess you figured it out, but I need something a bit more complex than the built-in filter.

Please send help :smiley:

how are you filling up this repeater? if it gets reconstructed, it might lose focus on things

It shouldn't be reconstructed, it depends on something that doesn't get updated.

I'll try to describe briefly how it works:

  • Dropdown selects a category
  • Repeater's instances are bound to a query that fetches the attributes of the items in that category that have a "filter" flag
  • Populate repeater with those attributes
  • The repeated view is in charge of displaying the right field type based on the attribute type (text field, dropdown, numeric field, checkbox...)

Once there, the instances are not reevaluated as long as you don't select another category.

what happends when you press tab? which input does it go to next?

Actually... I just added logging in the onBlur event of the text field and... It doesn't lose focus. It just stops doing anything.

I'll try on more recent versions, maybe with a simpler setup, and file a bug report with what I find.

update:
Doesn't happen with Firefox.
Happens with Chrome, Brave and Edge.
So I'm gonna assume it's a problem with chromium.

update again:
It doesn't happen either with a simpler setup (just one simple text field)

yet again another update:
New view, table filled with the default data (city, population...), just one text field.
No issue.
With my real table with real data, just one text field...
Issue.

Both setup are... very similar. Same bindings and filtering mechanism.
The only difference i can spot:
In the case where the issue appears, the source data is from a binding (but doesn't change while filtering), while in the case where it works that data is static.

I'm... confused.

Update, hopefully the final one:
So... The difference that makes the one not working finally work...
Columns. It had defined columns. Removing them made the text field work properly.
Can someone explain this to me ?

maybe here the columns seems to be gone, maybe this causes some focussing problems

I just updated the first post with a simple way to replicate the issue.
Try it, I'm sure you'll find this super weird too.

heh yea is weird, its not like the columns are getting focus instead.

seems like a bug

I don't think it's a focus issue, logging onBlur and onFocus events show that the text field doesn't lose it.
it just forgets how to be a text field.

yeah its not, i checked it with js and in js it still thinks the input is the activeelement.
(

window.setInterval(function(){
  console.log(document.activeElement)
}, 5000);

)

but its weekend for me now, and it looks like its something igntion will have to fix

Well... At least I can fix it with some dirty tricks.

self.view.getChild("root").focus()
self.focus()

On an onKeyUp event... Yea, I know :X

1 Like