Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong params passed to action when multiple actions from multiple controllers #766

Closed
jrmgx opened this issue May 18, 2024 · 4 comments
Closed

Comments

@jrmgx
Copy link

jrmgx commented May 18, 2024

On a link I have two actions from two different controllers chained like this:

<a data-action="click->sidebar#actionOne click->plan#actionTwo">

I have also added associated params for each action like that:

<a data-action="click->sidebar#actionOne click->plan#actionTwo"
  data-plan-tab-param="interests"
  data-sidebar-scroll-param="true"
  ...>

When I click on this link, I have both actions called, but in each one I receive the plan-tab param.

I expected to receive the plan-tab param in the plan action and the sidebar-scroll param in the sidebar action.

Note: if I reverse the order of the actions, putting first plan#actionTwo then I receive the sidebar-scroll param in both instead of the plan-tab one.

Stimulus 3.2.2

@ildarkayumov
Copy link

https://jsfiddle.net/ildarkayumov/02u9xjed/
I tried to create an example based on your code and it worked well
Screenshot 2024-06-02 at 11 21 19

can you try it by yourself and provide non-working example please?

@jrmgx
Copy link
Author

jrmgx commented Jun 3, 2024

Thank you for your time, it is exactly the case I was describing in my issue, but as you said it work well in your reproducer.

So I'm a bit confuse. It is probably on my side, there is no other explanation.

This is the actual code in context if you want to take a quick look.
Note: I'm not asking anything here, but it may talk to you, if you don't have time, no worries!

Action call: https://github.com/jrmgx/trailOdysseyOpen/blob/bd4c88826aa147221dfba22bff0f22aa74a3dcc1/templates/geo/elements_frame.html.twig#L44
Plan controller: https://github.com/jrmgx/trailOdysseyOpen/blob/bd4c88826aa147221dfba22bff0f22aa74a3dcc1/assets/controllers/plan_controller.js#L66
Sidebar controller: https://github.com/jrmgx/trailOdysseyOpen/blob/bd4c88826aa147221dfba22bff0f22aa74a3dcc1/assets/controllers/sidebar_controller.js#L67

If nothing seems obvious to you, let's close that issue as it certainly a bug inside my own code.

Sorry for the wasted energy, have a good day.

@ildarkayumov
Copy link

@jrmgx I see that you pass all params to all actions

data-plan-tab-param="interests"
data-plan-scroll-param="true"
data-sidebar-tab-param="interests"
data-sidebar-scroll-param="true"

what would happen if you pass only needed params like this ?

data-plan-tab-param="interests"
data-sidebar-scroll-param="true"

I tried to create a new example https://jsfiddle.net/ildarkayumov/28qnyL1u/ and it works well for me too

Screenshot 2024-06-04 at 13 13 37

@jrmgx
Copy link
Author

jrmgx commented Jun 4, 2024

Putting all parameters to all actions is my way of mitigating the issue, that's why.
But let's close it for now, there is something wrong on my side for sure. Thank you for your time, if I ever find out, I'll put a message here.

Have a good day

@jrmgx jrmgx closed this as completed Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants