Autocomplete with Multiselect Bug

Making a custom component that allows you to use the Anvil Extras autocomplete component to search for items, and add them to a selected item group, and also delete items from that selected item group.
Here’s what it looks like in action:

demo

All fine and dandy for a single instance of the custom component.

However… the way individual items get deleted, is, by publishing and subscribing on a single topic.

A user hits the button_delete, and it publishes a message on the topic auto_complete_item_delete.

The AutoCompleteInputWithError subscribes to this topic,

When there are multiple instances of this custom component, I run into errors as you expect. rows in instance 1 publish to everybody, not just the parent instance.

This is what that looks like:

error

I understand that using events like this is probably not the best solution, but I’m not sure how else to delete these individual rows from the repeating panels. I tried following and modifying one of the most basic To Do list apps, provided by anvil, but the methods to delete the element, only seem to work, if the data source is coming from the DataTables. I’m sure there must be another way.

Anvil To Do List App

Clone of My App

And yes, I do realize Anvil Extras does have a multi drop-down select.

Any help here or ideas are appreciated. Thanks and have a good day.

You’d be better off with normal Anvil events. They’re local to the form, and so each instance of a custom component will have its own set.

Here’s an example of sending an Anvil event from a repeating panel item to its enclosing form: Anvil | Login

2 Likes

@jshaffstall ,

Wow, that was a great suggestion. With some minor modifications I was able to fix the bug.

Thank you so much!

Link to the fixed version

1 Like