Problem getting variable to change

Im working on an advanced prototype of a filter and im trying to change the state of an object with the click of a different object.

Each object in the component “Checkbox Item” has the following naming:

  • Hint=false, Selected=false, State=default, Indeterminate=false (unchecked)
  • Hint=false, Selected=true, State=default, Indeterminate=false (checked)
  • Hint=false, Selected=false, State=default, Indeterminate=true (semi-checked)

Each of these object has 3 nested components/objects inside of it:

  • Check box
  • Text (this is not a variabel)
  • Amount → this has a nested object inside it called #Count

The idea is that when i press a checkbox, the #Amount boolean is set to True/False (based on state) and the #Count variable goes up + or - 1.

So far so good, i have gotten all the children/checkmarks below Arbetsmarknadsförvaltningen (6 in total) to a) show/hide #Acount, b) check/uncheck boxes and c) add/subtract 1 from #Count

The problem is that i want to make a more advanced function, where if more than one of the children under Arbetsmarknadsförvaltningen is set to True (checked), the checkbox in Arbetsmarknadsförvaltningen should be set to Indeterminate.

All of the children below Arbetsmarknadsförvaltningen has been connected to a boolean variable and their naming is Object 1 etc (until 6) If we look at the first child–> Livsmedelskontrollen, it has the following syntax:

Everyting works great but when i adde the last interaction, nothing happens. The lines are:

if #count > #total → created a number variable called #total with the value 6
set Avdelning parent → this is the variable i have connected to Arbetsmarknadsförvaltningen
Indeterminate == true

I dont know what im doing wrong, can anyone help me? Im not a programmer but i can understand the logic but right now i just dont know whats happening.

image

image

Hey @Holmstrand, thank you for reaching out! This case looks very interesting but also a bit complex and I tried to replicate this based on the screenshots and information you’re provided. But without a file access and a screen recording I am missing important context. Do you mind sending me a copy of your file and a screen recording if possible? Please invite support-share@figma.com directly as an editor (this won’t affect your billing at all). At this point it’s difficult to say if this is intended or not. When you share a copy of your file I am able to share it internally with the team and ask them if there are any workarounds for this.

Thank you for your help in advance!

I think I get what you want to achieve. First thing, I would consider indeterminate value is amongst the Selected:true/false. So this would just be 1 property (Checked/Unchecked/semiChecked). But this will mean that you’ll need to manage the checkboxes variable with a string instead of boolean.

Your children checkboxes’s logic is pretty much there, so I’ll leave that part be, but here’s the reference to mine if you need it.

As for the parent, I have a update loop object that tracks the total count of the children checkboxes constantly, which will update the parent checkbox’s state. Usually you would attach this logic to each of the child checkboxes, but with this object, I can manage this with just 1 object.


image

  • If [Count>0] and [Count<2], set [parent checkbox] to “semiChecked”
  • If [Count<=0], set [parent checkbox] to “Unchecked”
  • If [Count>=2], set [parent checkbox] to “Checked”

As for on tap on the parent checkbox:
image
Basically it’ll check everything if parent is unchecked, uncheck everything if parent is semi-checked or Checked. Count to update accordinly as well.

Hopefully this help!

1 Like

Hi Gayani,
I sent a DM to you

1 Like