Traits of type "color" do not work
Question
Hi @artf,
I had previously mentioned in a pull request that traits of type color do not work. At the time I didn't have a need for them, but now I do so I'd like to look into fixing it if you haven't already started on it. The bug is in the InputColor object when it calls model.setValueFromInput - traits don't have that method so it throws an error. What do you think is the best way to fix this? Does the Trait object need a setValueFromInput method? Or should InputColor change so that it's smart enough to call different methods for a Trait vs a Property? Perhaps something else?
My initial (hacky) experimentation show that changing all of the model.setValueFromInput lines in InputColor to this gets it pretty close to working...not sure if this is the right path to go down or not though:
model.setValueFromInput && model.setValueFromInput(cl, 0) || model.setTargetValue && model.setTargetValue(cl);
Answers (2)
Does the Trait object need a setValueFromInput method?
This leads to the duplication of code but still think this will gonna work better
// in Trait.js
setValueFromInput(value, final = 1, opts = {}) {
const toSet = { value };
this.set(toSet, { ...opts, avoidStore: 1});
// Have to trigger the change
if (final) {
this.set('value', '', opts);
this.set(toSet, opts);
}
},
moreover setTargetValue it's not actually a correct way because you have to update the model first (a listener will update the target later)
The real problem is a bad design from the start. To be correct I should have inside 'abstract/ui' an InputModel and its InputView (same for other types of input), then using them inside traits and styles. Basically, the structure has to be closer to what is done with properties inside style manager but there is a little bit more work to do -.-
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1696
Traits appear first time when draged custom component
Hi artf , i have created custom component and add traits for it , when dragging this component to editor and select it the setting traits w...
Issue #1859
Change an element type in editor
Hi, In my javascript i already create 2 components (type "A" and type "B) with their own traits. I create a context menu on both elements t...
Issue #1579
Border Color Issue
@artf There is bug in the border color if you drag a button on the editor and paste color like rgb(255, 0, 0) in border color and select an...
Issue #554
Prevent hover highlighter and prevent selecting certain components
Hi @artf, I would like to get your thoughts on the following 2 items before submitting a pull request. These are to satisfy requirements fo...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.