Closed luilliarcec closed 2 years ago
Maybe I can assure that the problem is the triple JS comparison ... I tried casting my Id to string and it really worked.
I'll be revamping the custom select component in a major release I'm working on right now, so hopefully this kind of issue will be addressed when I get the chance to work on it.
In the upcoming v7 release of this package, this shouldn't be an issue anymore with this component. I'm closing for now but feel free to re-open if it is still an issue in v7.
Laravel Form Components Version
v6.0.0
Laravel Version
v8.63.0
Alpine Version
v3.4.2
Bug description
When using the component outside of Livewire, the component breaks if the selected value is an integer but only when it is obtained from old, this happens because the value returned by old is transformed to a string. For example select Apple with key 1 when old returns it to me is "1".
As I mention. this happens after submitting and receiving the value of old.
I investigated the source code and the selectedKey property returns the correct array, however, this seems to be one more JS error due to the triple comparison that exists in the following lines of code.
custom-select.js#L185
custom-select.js#L187
However, it is a somewhat vague assessment, I have not tested it to be true, if changing said comparison solves the problem.
Steps to reproduce
Relevant log output
No response