Skip to content
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

new -> destroy does not restore preset choices #573

Closed
kzkn opened this issue Apr 9, 2019 · 1 comment · Fixed by #574
Closed

new -> destroy does not restore preset choices #573

kzkn opened this issue Apr 9, 2019 · 1 comment · Fixed by #574
Labels

Comments

@kzkn
Copy link
Contributor

kzkn commented Apr 9, 2019

I expect it restores passed input element to initial state, but was not.

https://github.com/jshjohnson/Choices#destroy

Usage: Kills the instance of Choices, removes all event listeners and returns passed input to its initial state.

I use the version 7.0.0.
Here is a code: https://gist.github.com/kzkn/43ddb8a52712661c75dfea2d79edeb56

@kzkn kzkn mentioned this issue Apr 9, 2019
@stale
Copy link

stale bot commented Jul 18, 2019

Thanks for contributing to this issue. As it has been 60 days since the last activity, this issue is being automatically closed. This is often because the request was already solved in some way and it just wasn't updated or it's no longer applicable. If that's not the case, please do feel free to either reopen this issue or open a new one. We'll gladly take a look again!

@stale stale bot added the stale label Jul 18, 2019
@stale stale bot closed this as completed Jul 28, 2019
jshjohnson pushed a commit that referenced this issue Nov 17, 2019
* add specs

* fix to restore preset choices after destroy

* avoid to modify `this.config.choices` directly

* Update cypress/integration/select-one.spec.js

Co-Authored-By: Josh Johnson <[email protected]>

* Update public/test/select-one.html

Co-Authored-By: Josh Johnson <[email protected]>

* Update public/test/select-one.html

Co-Authored-By: Josh Johnson <[email protected]>

* Update public/test/select-one.html

Co-Authored-By: Josh Johnson <[email protected]>

* Update public/test/select-one.html

Co-Authored-By: Josh Johnson <[email protected]>

* fix specs

* restoring passed element initial options

 - Save `passedElement.options` values as `this._presetOptions`
 - Restore saved `this._presetOptions` to `passedElement.options` on `destroy`
 - It avoids restoring options in `this.config.choices`

* Update cypress/integration/select-one.spec.js

Co-Authored-By: Josh Johnson <[email protected]>

* Update cypress/integration/select-one.spec.js

Co-Authored-By: Josh Johnson <[email protected]>

* Update public/test/select-one.html

Co-Authored-By: Josh Johnson <[email protected]>

* move preset options assignment statement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant