Skip to main content
LBeck0122
New Member
August 19, 2023
Question

Mouse leave interaction seems to be not working / won't set variable

So, I’m using some variables in my component. Here is the intended interaction:

In the table header, when you hover over the label, I want to show the sort and menu icons. (This is working via the mouse enter interaction setting the "X Column / Hover Active variable to true - it is false by default.)

When you stop hovering, the sort and the menu icon should go away. (This is not working with the mouse leave interaction. The hover state simply stays applied. I also tried setting the “Hover Active” variable (which is linked to visibility of the icons) to true while hovering, but that didn’t show the icons on hover at all.)

I am simply struggling with getting the icons to hide when the mouse leaves the area.

Why am I doing it like this instead of using a component to change the states. Well, I was. Except for the fact that variables do not work with nested states at the moment, so I had to break apart my components and get creative.

When you click on the menu icon, it sets a variable, “Active Column” - which is a string. It essentially just records the name of the column you clicked on.

If I click on PO #'s menu, Active Column’s value becomes “PO #”

This is used later when you click on “Filter” - this switches the overlay to the Column Filtering Overlay. There is a text field that is linked / populated by “Active Column.” It is intended to work exactly like Material UI’s column filtering on their X Data Grid.

So, when the filter column is opened, the text in the first field should be something like:

PO # contains _____________ ← which is a text input that allows them to search. So this is why I’m using variables for the hover state.

I created a demo with the gist. The first couple of columns work, I didn’t want to spend time recreating the entire file. (Can’t share source due to company policy.)

Here’s the Demo

This topic has been closed for replies.

12 replies

stunk1247
November 3, 2023

Yes, if you don’t have an outer frame to utilize already. I have my components that I want “hover” functionality already nested in another component, so I can easily put the outer frame onMouseEnter functionality there.

After playing with this “hack”, this is also not a great solution because if the mouse is moved too fast, it tends to miss the outer frame onMouseEnter and leaves multiple “hover” states enabled. I’m not sure if the sample rate is too low, but as long as the mouse doesn’t move too fast, it tends to work.

MaxZuman
November 13, 2023

I think it all grows from the same garden – the laggishness with which the prototype engine works just adds to every interaction a chance to skip some interactions to happen. If you move the mouse really slow - then both onEnter and onLeave will work fine (should work at least), with the hack of moving the onLeave to another shape we are only giving the machine some more chances to catch the gears, but we dont eliminate the fundamental problem. I believe core crew at Figma knows about this but it might need to fully rewrite the core with some proper programming language to work fast