Figma Support Forum

Resetting component states between frames

Just struck a pretty simple use case/scenario where I need the component to reset it’s state when I leave the frame. This has been touched on elsewhere, but this is such a common and key use that I thought I’d put it in it’s own thread.

Scenario:
I’ve got a dropdown menu with three items in it, with each item changing what columns are visible in a table and some other control states. I have three frames, each with a view of the table setup as it should be, and want to use the dropdown items to navigate between the frames - basically faking the table state change. All of this works perfectly, however when I navigate back to a previous table view state, the dropdown component is already in it’s open state - not what I want.

Current workaround: none that I can come up with (other than not using interactive components at all for this, and just using multiple frames for the dropdown open/closed states as I would previously)

Suggestions:

  1. Have a “reset component on leaving this frame” setting for instances of a component on a frame - useful for this situation and others, but needs to be a setting so that components that should keep their state between frames can do so (light/dark toggle maybe? Something like that).
  2. Do it all in a single frame, with the dropdown component changing the the state of the table component - no frame navigation required. Would work nicely for the particular use case I’m working with here, but not sure it would solve all similar situations.
  3. Do both 1 and 2. This solution is my preferred solution :wink: :laughing:

EDIT:
Other threads that relate:

1 Like

Right now, I don’t think you can do it natively. The workaround I use is to open in overlay the components you want to reset. Since an overlay is destroyed and created each time, it will reset your interactive component. The main limitation to this, since you can only have one overlay at a time, is that you cannot use other overlays. At least this is a workaround.

This is so annoying…
@Nicolas_Demange workaround doesn’t work in my case for multiple reasons:

  1. I don’t want to let the user get in that state using arrow keys;
  2. I cannot use it with After Delay, even if I close the overlay before everything finish.

Can we get an official response about how we can reset the state of the interactive component to the initial or desired one?

1 Like

I’m sad to say, I’ve had to fall back to disconnecting all the component interactions, and then creating individual screen-level frames (screen x dropdown open, screen x dropdown closed) and all the combinatorial spaghetti that goes with that :cry: Hopefully we’ll hear something about the issue soon.

2 Likes

I’ve just run into this as well and it’s a pretty giant limitation I didn’t expect. Tough problem to solve, hope they have something for it soon.

But basically I can’t use interactive components in about half the cases I’d expect to be able to at this point.

2 Likes

Yes, at this point I’m only using IC for simple, non-nested hover states :cry:

I definitely hope this gets addressed (or at least acknowledged) during the beta. I’m able to use the overlay hack mentioned above in some, but not all cases.

1 Like

Would something like this solve the issue?

Something like this, yes :+1: But I think it belongs on the prototype tab of the sidebar, so that it’s alongside all the other prototyping settings for the component.