Unable to Deselect Chip (anvil extras)

Hello – I am trying to use the chip component from anvil extras, but keep running into an issue. I can select the chip but I am unable to deselect it even by using the close link.

Here is the sample of code I have for clicking and close clicking one of the chips:
def app_web_chip_1_click(self, **event_args):

def app_web_chip_1_click(self, **event_args):
“”“This method is called when the chip is clicked”“”
self.app_web_chip_1.background = “theme:Primary”

def app_web_chip_1_close_click(self, **event_args):
“”“This method is called when the close link is clicked”“”
self.app_web_chip_1.background = “theme:On Primary Container”

I have also tried getting rid of the close icon and just having the an if statement in the click button.

When you say deselect are you trying to get it to remove itself from its parent container?
You need to add an event handler to the close_click event, something like this (untested).

new_chip = Chip()
new_chip.set_event_handler('close-click', self.chip_close_click)

def chip_close_click(self, sender, **event_args):

Can you share a link to a clone that we can have a look at?

1 Like

Thank you! I will try this. I have been trying to create a clone of my app but I am having some issues with it opening on my end so I can remove some of the more sensitive data. In the meantime I will try to recreate some of the issues in a new app that I can share.