SOLVED: Interactions on Classes?

Browser: Chrome 110
OS: macOS / Windows / Linux / etc.
URL: Link to a page that illustrates this issue
Video: Short screen recording that illustrates this issue (free tool: jam.dev)

Hi

I am trying to use interactions on a selected class, which I can add just fine, and it’s different options to the main element / ID. But when I click off them, they then disappear and don’t save on the element?

I have to do this, as I am trying to toggle a data-attribute based on a class - but it then toggles it on EACH class on that page each time any of them are in viewport (I don’t have to have to copy and paste the interaction to EACH element, it would take ages and be hard to scale).

Many thanks

@Matej - not sure if you can help with this dude?

Hi @robp,

at first, I thought this is 100% not a bug, and I’m still quite certain now as well. But, just to be sure, can you record a video on how to replicate the issue, and what is your setup?

Below are some comments:

Interaction should be store on the class.

Yes, because the selector is like that likely. You can’t really say “toggle on nearest element only” - you would need JS for that.

Best regards,
Matej

Hi @Matej

Thank you.

Yes I thought that, but it doesn’t save on the class - at all? It just saves to the ID/core element - it’s different for you?

I understand. I didn’t want it to toggle on nearest element, but I don’t want it to toggle classes that are not in the viewport - as in this instance, I am using the data-attribute to start/stop an animation. This won’t work as the attribute is added to all classes on that page, and as such, the animation fires on all of them - if that makes sense.

I wanted to add the interaction to the class so I can easily add/toggle this effect on elements without having to keep copying and pasting conditions from IDs.

Hi @robp,

It should be saved on the class (in builder), but on frontend, the interaction is still applied on all elements that have that class.

I will toggle everywhere that you target it, including the elements that are not in the viewport.

I think it’s best if you can record the video of your setup and what you want to achieve + show the issue, where the interaction is added to ID not the class.

Thank you,
Matej

Hey @Matej

Fair point, I hope this helps to clear that up:

Many thanks

Hi @robp,

thanks for the video. So, the way I think it could work is with the following changes:

  1. Add an interaction to the class.
  2. As a target, set “self”
  3. Update your CSS to animate the span inside, if the heading has that attribute.

Would that work?

Matej

Hi @Matej

That sounds like it could work, for sure, but the interaction was sticking to the class for me if you noticed in that video? Was that solely due to me setting it as class and not self though?

I’m sure I tried it with self first, and changed as nothing was saving to the class.

Many thanks

Yeah just tried it again now mate, and it won’t save any interactions to the class?

I click the class, add an interaction, complete it, click off it, unselect the class and reselect, and it’s empty?

Hi @robp,

I think in this case is best if I take a look. If you can prepare a staging website or just a page and a class where I can check this, it would be best if can send temporary login credentials a link to this topic to help@bricksbuilder.io using the email address you used during the purchase, so we I take a look?

Thank you,
Matej

Hi @robp,

thank you for the email and access. It looks like there is an issue with adding interactions to classes and updating interactions that are set on classes.
I was able to replicate that issue as well on the local installation, and I’ve created an internal bug report.

We will fix this and once we do, we will update this topic. Until then, you will have to set interactions on ID level.

Thank you,
Matej

Hi Matej. Thanks for confirming my issue.

We fixed this issue in Bricks 2.1.3, now available as a one-click update in your WordPress Dashboard.

Please take your time to read the changelog entry before updating, and let us know if you continue to experience issues.