Closed sinankeskin closed 3 years ago
Thanks I'll take a look
What is:
el.value
in this case?
And what is {{locationType}}
LocationType is an ember model and el.value is a Proxy of LocationType. ember-changeset does that.
I have set up a demo: https://github.com/amk221/-ember-select-box-ember-changeset/blob/main/app/routes/application.js#L13
Just testing a bit more before I come back with an answer
An object !==
to a proxy of that object - so I don't see how that could ever have worked?
Under the hood the select box addon has always used ===
to tell whether an option is selected.
Perhaps something else in your code has changed?
Note that Ember Data async relationships are Promise Proxy Objects under the hood. So when these resolve, the comparison is actually model === model
, not model === proxy
, so that will work.
If you can create a reproduction, I can better understand your situation.
An object
!==
to a proxy of that object - so I don't see how that could ever have worked? Under the hood the select box addon has always used===
to tell whether an option is selected.Perhaps something else in your code has changed?
Note that Ember Data async relationships are Promise Proxy Objects under the hood. So when these resolve, the comparison is actually
model === model
, notmodel === proxy
, so that will work.
You are absolutly right but this test doesn't cover my case. In this line this.bar2 is an actual model. peekRecord returns model.
But in my case this.bar2 is a Promise Proxy object.
<SelectBox @value={{this.bar2}} as |sb|>
I will investigate deeply in your demo app. Thank you.
Here is my demo app but interestingly this works flawless. But same logic in my production app doesn't work.
Really odd. I don't know what am I missing. Thank you.
Hmmm. Sorry I can't help any further. Do you mind if I close for now?
Good luck, I'd be interested to know what it is - feel free to post back!
In my case this line option.args.selectBox.value;
in ember-changeset 2.x returns model but in ember-changeset 3.x returns Proxy. Same app only ember-changeset upgraded. Thats why selected item doesn't show.
In this line value is model now.
But in here selectBox.value
still shows Proxy. I believe value changes doesn't affect selectBox object.
I see. So all your @locationTypes
were models. but, the select box's value was a proxy to a locationType
.
Yes. Correct.
Hi @amk221
Any news on this? Thank you.
Ah, sorry I didn't realise you were waiting for a response. I thought from the above that it's clear to not be an issue with this addon?
Hımm ok. I'll unwrap the proxy then.
Thank you for everything 👍🏻
Curious what other select-box addons would do in this situation? Have you tried ember-power-select?
Actually I have. ember-power-select resolves succesfully. Because of selected item type any or PromiseProxy it works as expected.
Here is the screenshot:
Looks like they reach into proxy.content
too. Not something I want to do I'm afraid.
Additionally, the displayed option is rendered correctly, but, the option corresponding to the value is not flagged as selected. See this screenshot:
Understood. Thank you again.
First of all thanks for this addon. I'm always using latest version.
I have a NativeSelectBox like this. I don't know if ember responsible or not but my value is proxy object because of models belongs_to relation and changeset.
This selectbox was working before but not anymore. I've researched deeply and found out that I was using changeset 2.x and I've updated to 3.x recently. Somehow changeset's pxoxy objects slightly different between 2.x and 3.x.
Long story short NativeSelectBox doesn't show selected object with ember-changeset 3.x
Thank you.