Chip tag initialization

What I’m trying to do:
Initialize a chip tag in one step.

What I’ve tried and what’s not working:
Declare the Chip with tag value in the same statement. However checking the value immediately afterwards you can see that it isn’t being applied. If I use multiple statements, as shown below, it works.

Code Sample:

mychip = Chip(text='"foo", tag="bar", close_icon=True, background="#ef6603", foreground="black")
print(f"mychip tag = {mychip.tag}")
next_chip = Chip()
next_chip.tag = "nextchip"
print(f"next_chip tag = {next_chip.tag}")

mychip.tag will be set to the generic tag object ComponentTag({}).
next_chip.tag will be set correctly

That’s a quirk of the CustomComponent system
expect a fix for that soon:

add tag property to custom components in the same way we do visible by s-cork · Pull Request #391 · anvilistas/anvil-extras · GitHub

1 Like