Skip to main content
vernikr
New Participant
January 27, 2024
Question

Bug when switching variable modes in nested components

  • January 27, 2024
  • 52 replies
  • 4120 views

I’m trying to switch a variant of component instance by switching variable mode. This works perfect once the component A is on top level and not nested.

But if I nest component A into component B and then change the variable, the instance of component A still changes the variant as supposed but this also resets all other other properties of comp A to their defaults.

This doesn’t happen when comp A is not nested.

Tried with several components even with the simplest created from scratch.

This topic doesn’t relate to prototypes and interactivity.

This topic has been closed for replies.

52 replies

djv
Figmate
Community Support
January 29, 2024

Hey @vernikr, sorry to hear this is happening!

It’s hard to be sure exactly why this is occurring without seeing your file.

Are you able to share a link, so that we here in the community can take a closer look?

March 3, 2024

I’m also having this issue, here are the steps I’ve found that reproduce the issue:

  1. Create a component with a text layer
  2. (Optional - doesn’t affect the outcome) Assign the text layer value to a text property
  3. Create 2 variants for the component (e.g. Device: Mobile & Desktop)
  4. Create a variable collection with 2 modes (e.g. Mobile & Desktop)
  5. Create a string variable device that matches the 2 variant names (e.g. Mobile & Desktop)
  6. Nest an instance of the component in another component
  7. Override the nested component string
  8. Connect the nested component variant property to the file variable “device”
  9. Create 2 sections, each with the mobile or desktop mode assigned
  10. Drag an instance of the parent component between the sections and you’ll see the string is reset when the mode changes to the non-default mode.

Hope this helps fix the bug!

Julia57
Active Member
April 18, 2024

This has been a general issue with nesting and variables. it simply doesnt work. I have size variables attached to my icons (they change size based on breakpoints). I nest them like so: icon > navigation item > navigation drawer.
Changing the variables on the icon size does not update the instances inside navigation drawer. Reassigning the icon size on the navigation item ALSO does not update inside ethe navigation drawer. This is a massively distruptive breaking factor in the entire workflow.

EZ_Obtera
New Member
May 13, 2024

Hi. I am having the same issue.

image

The icon in the button is a nested component, using an instance of components from another Figma library (Brand A and Brand B icons). This nested component has two variants, one for each “brand.”

When used in the Button component, a string variable is assigned to the icon’s property so it can dynamically switch between variants when a variable mode is selected.

I can share my Figma if it helps. Thank you.

EZ_Obtera
New Member
May 13, 2024

The issue I am having is when I switch the variable mode, the icon disappears.

Figma file: click here

VincentP23
New Member
May 13, 2024

Hi EZ, I’m having the exact same issue… the Brand B icon disappears when swapping brand modes.

Hopefully, this gets more traction as it’s a huge benefit to allow designers to easily swap icons from Brand A to Brand B in our UI Kit component.

y_toku
Figmate
Community Support
May 14, 2024

Hi there,

Thanks for flagging this issue. I shared this issue with our internal team. I can’t guarantee if this issue will be fixed soon, but I will get back to you if there is anything that can share with you.

Thanks,
Toku

Alexey_Kolesnikov
May 14, 2024

Similar problem. We have platforms in variables and a dark theme. With multiple levels of nesting, the components disappear when we switch the theme. I found a temporary solution, if you remove the link in the child component, then when you duplicate the component (which did not disable the link) everything starts working. And at the same time in other child components when double clicking everything appears. I attach a video instruction as I was able to temporarily cure the bug. After updating the file, I have to repeat the actions.

P.S. The bug often occurs when all components are in file A, and working with layouts in file B

y_toku
Figmate
Community Support
May 15, 2024

Thanks for the additional information! I also shared your recording internally. Really appreciate it.

Franni
New Participant
May 22, 2024

Hello 🙂 same/similar problem!
Our table should offer different row heights. Depending on the row height, the buttons, inputs etc. inserted in a single cell should also be displayed in different heights (Default, Small or Large). I wanted to solve this with modes instead of a separate variant per cell per row height. This means, for example, that I control the size of the embedded input field via a string variable per mode. However, if I now change the instance of this via Mode, the other properties of the embedded input field are reset. This is of course not the desired behaviour.

Edit: Another annoying thing: when the embedded element in the cell is switched to a bigger/smaller variant the cell resizing which is set to “filled” will be overwritten to “fixed” instead…

See screen recording on YouTube (Forum says 8MB is the maximum, Mac says the recording is 5MB but yeah… xD it’s on YouTube now)