mirror of
https://github.com/Choices-js/Choices.git
synced 2024-06-02 05:52:14 +02:00
Resolve bug with text value
This commit is contained in:
parent
0f7cbfb6bf
commit
1f06a32b30
|
@ -83,8 +83,6 @@ describe('Choices - text element', () => {
|
||||||
cy.get('[data-test-hook=basic]')
|
cy.get('[data-test-hook=basic]')
|
||||||
.find('.choices__input--cloned')
|
.find('.choices__input--cloned')
|
||||||
.type(`${textInput}`)
|
.type(`${textInput}`)
|
||||||
.type('{enter}')
|
|
||||||
.type(`${textInput}`)
|
|
||||||
.type('{enter}');
|
.type('{enter}');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -93,7 +91,7 @@ describe('Choices - text element', () => {
|
||||||
.find('.choices__list--multiple')
|
.find('.choices__list--multiple')
|
||||||
.children()
|
.children()
|
||||||
.should($items => {
|
.should($items => {
|
||||||
expect($items.length).to.equal(2);
|
expect($items.length).to.equal(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
cy.get('[data-test-hook=basic]')
|
cy.get('[data-test-hook=basic]')
|
||||||
|
@ -104,10 +102,24 @@ describe('Choices - text element', () => {
|
||||||
.click();
|
.click();
|
||||||
|
|
||||||
cy.get('[data-test-hook=basic]')
|
cy.get('[data-test-hook=basic]')
|
||||||
.find('.choices__list--multiple')
|
.find('.choices__list--multiple .choices__item')
|
||||||
.first()
|
|
||||||
.should($items => {
|
.should($items => {
|
||||||
expect($items.length).to.equal(1);
|
expect($items.length).to.equal(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('updates the value of the original input', () => {
|
||||||
|
cy.get('[data-test-hook=basic]')
|
||||||
|
.find('.choices__list--multiple .choices__item')
|
||||||
|
.last()
|
||||||
|
.find('.choices__button')
|
||||||
|
.focus()
|
||||||
|
.click();
|
||||||
|
|
||||||
|
cy.get('[data-test-hook=basic]')
|
||||||
|
.find('.choices__input.is-hidden')
|
||||||
|
.then($input => {
|
||||||
|
expect($input.val()).to.not.contain(textInput);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -23,13 +23,6 @@
|
||||||
<link rel="stylesheet" href="../assets/styles/choices.min.css?version=3.0.2">
|
<link rel="stylesheet" href="../assets/styles/choices.min.css?version=3.0.2">
|
||||||
<script src="../assets/scripts/choices.min.js?version=2.8.8"></script>
|
<script src="../assets/scripts/choices.min.js?version=2.8.8"></script>
|
||||||
<!-- End Choices includes -->
|
<!-- End Choices includes -->
|
||||||
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<style>
|
|
||||||
.hidden-ie { display: none; }
|
|
||||||
.visible-ie { display: block; }
|
|
||||||
</style>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -577,15 +577,13 @@ class Choices {
|
||||||
const activeItems = this._store.activeItems || [];
|
const activeItems = this._store.activeItems || [];
|
||||||
this.itemList.clear();
|
this.itemList.clear();
|
||||||
|
|
||||||
if (activeItems.length) {
|
// Create a fragment to store our list items
|
||||||
// Create a fragment to store our list items
|
// (so we don't have to update the DOM for each item)
|
||||||
// (so we don't have to update the DOM for each item)
|
const itemListFragment = this._createItemsFragment(activeItems);
|
||||||
const itemListFragment = this._createItemsFragment(activeItems);
|
|
||||||
|
|
||||||
// If we have items to add, append them
|
// If we have items to add, append them
|
||||||
if (itemListFragment.childNodes) {
|
if (itemListFragment.childNodes) {
|
||||||
this.itemList.append(itemListFragment);
|
this.itemList.append(itemListFragment);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue