mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-23 16:02:21 +02:00
Disable input when loading remote data
This commit is contained in:
parent
307881a068
commit
496db95153
|
@ -520,16 +520,13 @@ describe('Choices - select multiple', () => {
|
|||
.should('have.attr', 'placeholder', 'Loading...');
|
||||
});
|
||||
|
||||
describe('opening the dropdown', () => {
|
||||
it('displays "no choices to choose" prompt', () => {
|
||||
cy.get('[data-test-hook=remote-data]').click();
|
||||
describe('on click', () => {
|
||||
it('does not opens choice dropdown', () => {
|
||||
cy.get('[data-test-hook=remote-data]')
|
||||
.find('.choices')
|
||||
.click()
|
||||
.find('.choices__list--dropdown')
|
||||
.should('be.visible')
|
||||
.should($dropdown => {
|
||||
const dropdownText = $dropdown.text().trim();
|
||||
expect(dropdownText).to.equal('No choices to choose from');
|
||||
});
|
||||
.should('not.have.class', 'is-active');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -471,16 +471,13 @@ describe('Choices - select one', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('opening the dropdown', () => {
|
||||
it('displays "no choices to choose" prompt', () => {
|
||||
cy.get('[data-test-hook=remote-data]').click();
|
||||
describe('on click', () => {
|
||||
it('does not opens choice dropdown', () => {
|
||||
cy.get('[data-test-hook=remote-data]')
|
||||
.find('.choices')
|
||||
.click()
|
||||
.find('.choices__list--dropdown')
|
||||
.should('be.visible')
|
||||
.should($dropdown => {
|
||||
const dropdownText = $dropdown.text().trim();
|
||||
expect(dropdownText).to.equal('No choices to choose from');
|
||||
});
|
||||
.should('not.have.class', 'is-active');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -874,8 +874,11 @@ class Choices {
|
|||
let placeholderItem = this.itemList.getChild(
|
||||
`.${this.config.classNames.placeholder}`,
|
||||
);
|
||||
|
||||
if (isLoading) {
|
||||
this.disable();
|
||||
this.containerOuter.addLoadingState();
|
||||
|
||||
if (this._isSelectOneElement) {
|
||||
if (!placeholderItem) {
|
||||
placeholderItem = this._getTemplate(
|
||||
|
@ -890,6 +893,7 @@ class Choices {
|
|||
this.input.placeholder = this.config.loadingText;
|
||||
}
|
||||
} else {
|
||||
this.enable();
|
||||
this.containerOuter.removeLoadingState();
|
||||
|
||||
if (this._isSelectOneElement) {
|
||||
|
|
Loading…
Reference in a new issue