question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sending actions from the selectedItemComponent

See original GitHub issue

This is a feature request, but it needs some fleshing out.

I want to be able to interact with the selectedItem in a multiple-select. My particular case needs to allow the user to click/touch the selected items to do “things”.

Using selectedItemComponent makes this easy, however I want to trigger actions from the component and bubble them up.

Should there be a way to pass actions closures into the selectedItemComponent? Or is the right way to do this using Evented or a Service?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:20 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
Ramblurrcommented, Mar 22, 2016

Yup, thanks for the support @cibernox.

For those that land here eventually, here is how I was able to interact with my selectedItemComponent without having to extend the trigger. In my case “interact” meant handling click events on the selected items.

// in my-select-component.hbs
{{#power-select-multiple
...
selectedItemComponent=(component "selected-item" onItemClicked=(action "itemClicked") someValues=stuff)
...

Then in selected-item.js

...
  didInsertElement() {
    this._super(...arguments);
    this.element.addEventListener('mousedown', (e) => {
          e.stopPropagation();
          return false;
    });
  },
...
2reactions
cibernoxcommented, Mar 18, 2016

Contextual components are ideal for this.

{{#power-select options=opts 
  selected=foo onchange=(...) 
  selectedItemComponent=(component "my-custom-component" doStuff=(action "foobar")) as |opt|}}
  {{opt}}
{{/power-select}}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Sending Actions from Components to Your Application
Luckily, components have a sendAction() method that allows them to send actions specified when the component is used in a template. Sending a...
Read more >
Sending action from component to route in ember.js
This action helper will point to an action of your controller, in your component you can call this.attrs.closeModal() or this.get('closeModal')() ...
Read more >
Launch a Flyout from an Action on a FlexCard - Salesforce Help
From the FlexCard Designer, drag an Action element into a state. Select ... Click into the Flyout field and select a component to...
Read more >
Data down actions up | Component side effects - EmberMap
When a component's side effects will change from one use case to the next, those side effects should be handled using "actions up"...
Read more >
How To Manage State in React with Redux - DigitalOcean
To access items in your Redux store, use a Hook called useSelector ... Your components will send the actions they want your store...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found