New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User-defined types not normalized properly when passed in as data #4632
Comments
This appears to be a duplicate of #4438, which was closed due to lack of activity. Can you create a jsbin that replicates this behavior? I guess I don't know how jQuery decides when an object is a "plain object". I found this documentation on Plain objects, but it doesn't mention how it treats user-defined types (like the |
Hi, I created a sample that recreates the problem: https://jsbin.com/riyamuyixi/edit?html,js,output |
Thanks. I've made this fork which shows that the bug only affects user-defined types: https://jsbin.com/cufawefalu/edit?html,js,console,output |
Hi, What do you think about changing the call to isPlainObject by:
Source: https://stackoverflow.com/a/14706877/1038133 I have tested with this data and all cases have worked::
|
This could be a good solution. Keep in mind that Select2 also supports grouped data, so this should probably be tested as well. Can you submit a pull request that makes the change, and also adds some additional tests for these cases? |
Hi, I tested manually with grouped data and it worked
Where dou you want me to put the tests? Should I made a new module? |
Awesome! So, automated tests are written with qunit, and go in https://github.com/select2/select2/tree/master/tests. It seems like the test for user-defined types should go in either https://github.com/select2/select2/blob/master/tests/data/array-tests.js or https://github.com/select2/select2/blob/master/tests/data/select-tests.js (possibly both). |
#5093 fixes this, and has been merged in to the 4.0.6-rc.0 pre-release. |
In the last version 4.0.13 I had to comment that line out:
as my text object contans several fields like |
Prerequisites
master
branch of Select2Steps to reproduce the issue
Initialize select 2 like this:
Expected behavior and actual behavior
When I follow those steps I see that the text of the options is: [object Object]
I was expecting it to be: aaaaaa, aaaaaa2 and aaaaaa3
According to what I have been able to investigate, the problem is here:
Environment
Browsers
Operating System
Libraries
Isolating the problem
The text was updated successfully, but these errors were encountered: