# Text field stops working unexpectedly

**URL:** <https://forum.inductiveautomation.com/t/text-field-stops-working-unexpectedly/74453>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [June 1, 2023, 3:58pm UTC](https://forum.inductiveautomation.com/t/text-field-stops-working-unexpectedly/74453 "2023-06-01T15:58:43Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 1, 2023, 3:58pm UTC](https://forum.inductiveautomation.com/t/text-field-stops-working-unexpectedly/74453/1 "2023-06-01T15:58:43Z")

</div>

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:

```python
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:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/3/03814510e53fad1c81048b0a091f70797e42d299.png)  
Text field has focus.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/d/cd56ebb3f374a1e7c687df865a536139e9cbcc4e.png)  
Nothing changed in the table, text field still has focus.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/d/9db7df882d833ee33279a902e270ccbe5d929cba.png)  
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](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/d/ddbac8e017161e7e3e6edc2dd94f235f2c2fd8fe.png)  
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.

```python
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...

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 2, 2023, 7:20am UTC](https://forum.inductiveautomation.com/t/text-field-stops-working-unexpectedly/74453/3 "2023-06-02T07:20:26Z")

</div>

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

Please send help 😃

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [June 2, 2023, 7:32am UTC](https://forum.inductiveautomation.com/t/text-field-stops-working-unexpectedly/74453/4 "2023-06-02T07:32:55Z")

</div>

> [@pascal.fragnoud](#):
>
> in a flex repeater

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

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 2, 2023, 7:41am UTC](https://forum.inductiveautomation.com/t/text-field-stops-working-unexpectedly/74453/5 "2023-06-02T07:41:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [June 2, 2023, 7:45am UTC](https://forum.inductiveautomation.com/t/text-field-stops-working-unexpectedly/74453/6 "2023-06-02T07:45:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 2, 2023, 8:03am UTC](https://forum.inductiveautomation.com/t/text-field-stops-working-unexpectedly/74453/7 "2023-06-02T08:03:41Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [June 2, 2023, 12:23pm UTC](https://forum.inductiveautomation.com/t/text-field-stops-working-unexpectedly/74453/8 "2023-06-02T12:23:42Z")

</div>

> [@pascal.fragnoud](#):
>
> ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/d/9db7df882d833ee33279a902e270ccbe5d929cba.png)

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

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 2, 2023, 12:27pm UTC](https://forum.inductiveautomation.com/t/text-field-stops-working-unexpectedly/74453/9 "2023-06-02T12:27:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [June 2, 2023, 12:57pm UTC](https://forum.inductiveautomation.com/t/text-field-stops-working-unexpectedly/74453/10 "2023-06-02T12:57:36Z")

</div>

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

seems like a bug

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 2, 2023, 12:59pm UTC](https://forum.inductiveautomation.com/t/text-field-stops-working-unexpectedly/74453/11 "2023-06-02T12:59:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [June 2, 2023, 1:01pm UTC](https://forum.inductiveautomation.com/t/text-field-stops-working-unexpectedly/74453/12 "2023-06-02T13:01:25Z")

</div>

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

```auto
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

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 2, 2023, 1:15pm UTC](https://forum.inductiveautomation.com/t/text-field-stops-working-unexpectedly/74453/13 "2023-06-02T13:15:08Z")

</div>

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

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

```

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

---

<div class="post-metadata">

**Author:** ![BVTV](https://avatars.discourse-cdn.com/v4/letter/b/e5b9ba/32.png) [@BVTV](https://forum.inductiveautomation.com/u/BVTV)\
**Post date:** [March 27, 2024, 7:59am UTC](https://forum.inductiveautomation.com/t/text-field-stops-working-unexpectedly/74453/14 "2024-03-27T07:59:00Z")

</div>

Stumbled upon the same problem in Ignition 8.1.35.  
I am also using a textfield to filter the content of a table. When I filter on something that causes the table to become empty, I am not able to write more characters. Have to click in the textarea again to continue.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [March 27, 2024, 2:04pm UTC](https://forum.inductiveautomation.com/t/text-field-stops-working-unexpectedly/74453/15 "2024-03-27T14:04:32Z")

</div>

I doubt this get fixed anytime soon, if IA can even do anything about it.  
Maybe they can, maybe it's chromium's job, frankly I have no clue and I guess it's too rare of an edge case to get worked on.

In the meantime, I guess you can use the hack I posted above.

---

<div class="post-metadata">

**Author:** ![BVTV](https://avatars.discourse-cdn.com/v4/letter/b/e5b9ba/32.png) [@BVTV](https://forum.inductiveautomation.com/u/BVTV)\
**Post date:** [March 27, 2024, 2:21pm UTC](https://forum.inductiveautomation.com/t/text-field-stops-working-unexpectedly/74453/16 "2024-03-27T14:21:29Z")

</div>

You're probably right. I will try your hack!

---

<div class="post-metadata">

**Author:** ![Phillip\_Hail](https://avatars.discourse-cdn.com/v4/letter/p/b487fb/32.png) [@Phillip\_Hail](https://forum.inductiveautomation.com/u/Phillip_Hail)\
**Post date:** [January 21, 2025, 9:20pm UTC](https://forum.inductiveautomation.com/t/text-field-stops-working-unexpectedly/74453/17 "2025-01-21T21:20:07Z")

</div>

Having the same issue, also using a text field to filter a table and when the table becomes empty the text field stops working.
