You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Disclaimer: To be honest, this is a kinda special setup.
I have a modal window whose content contains a select field that is used to initialize Choices.js. There are two scopes where this modal may be opened:
in a simple standalone view
in a more complex environment with an iframe, where the modal is rendered in the top frame
In the latter case, I get the error "Expected one of the following types text|select-one|select-multiple". The issue is that the instanceof check for the passed element to initialize Choices.js does not work in case of an inter-frame communication. In my tests it was safe to check passedElement.constructor.name instead.
Since the fix is rather easy I'll push a PR ASAP.
To Reproduce
Steps to reproduce the behavior:
In the iframe, have a callback that initializes Choices.js
Open a modal with the matching select element on the top frame
Execute the callback
See "Expected one of the following types text|select-one|select-multiple"
Expected behavior
I expect that Choices.js works in the scenarios mentioned above.
Desktop (please complete the following information):
OS: Fedora Linux 36
Browser Chrome
Version 105
The text was updated successfully, but these errors were encountered:
+1 for me as well, I found that the issue is probably because of the use of instanceOf on ChoiceJS before initialization. On iframe this is unreliable. There could be also be some potential issues when the proto chain has been modified for some reason as well.
I think the best solution here would be to replace instanceOf check for something else like nodeName or anything else that is constant and persistent.
Xon
added a commit
to Xon/Choices.js
that referenced
this issue
Aug 9, 2024
Describe the bug
Disclaimer: To be honest, this is a kinda special setup.
I have a modal window whose content contains a
select
field that is used to initialize Choices.js. There are two scopes where this modal may be opened:iframe
, where the modal is rendered in the top frameIn the latter case, I get the error "Expected one of the following types text|select-one|select-multiple". The issue is that the
instanceof
check for the passed element to initialize Choices.js does not work in case of an inter-frame communication. In my tests it was safe to checkpassedElement.constructor.name
instead.Since the fix is rather easy I'll push a PR ASAP.
To Reproduce
Steps to reproduce the behavior:
select
element on the top frameExpected behavior
I expect that Choices.js works in the scenarios mentioned above.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: