ember-colpick icon indicating copy to clipboard operation
ember-colpick copied to clipboard

Feature/value change action

Open jdurand opened this issue 6 years ago • 0 comments

This PR makes sure an onChange event (https://github.com/yapplabs/ember-colpick/pull/18) is sent & the value is set only of a user interaction caused the value to change (see: https://github.com/mrgrain/colpick bySetColor flag).

This also allows the component to be used in a data-down/actions-up way (without 2-way binding on value).

// components/col-pick-button.js
import Component from '@ember/component';
import ColPickMixin from 'ember-colpick/mixins/col-pick';

export default Component.extend(ColPickMixin, {
  flat: false
});
{{!-- hello.hbs --}}
{{#col-pick-button value=(unbound record.color) onChange=(action 'colorUpdated' record)}}
  Hello
{{/col-pick-button}}

Without this, the component is exposed to some unpredictable 2-way binding side-effects; combine this and WebSocket updates and you may get XMas tree lights on your production app 😅.

I'm running this branch in production BTW:

3a78115eb1231c015ce9b58be77f1ef2

jdurand avatar Apr 11 '18 20:04 jdurand