mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-02 05:52:46 +02:00
Do not open dropdown if element is disabled
This commit is contained in:
parent
798b49d565
commit
b0f3b28ef4
|
@ -292,31 +292,10 @@ describe('Choices - select multiple', () => {
|
|||
});
|
||||
|
||||
describe('on click', () => {
|
||||
it('opens choice dropdown', () => {
|
||||
it('does not open choice dropdown', () => {
|
||||
cy.get('[data-test-hook=add-items-disabled]')
|
||||
.find('.choices__list--dropdown')
|
||||
.should('be.visible');
|
||||
});
|
||||
});
|
||||
|
||||
describe('attempting to select choice', () => {
|
||||
let selectedChoice;
|
||||
|
||||
it('does not select choice', () => {
|
||||
cy.get('[data-test-hook=add-items-disabled]')
|
||||
.find('.choices__list--dropdown .choices__item')
|
||||
.last()
|
||||
.then($lastChoice => {
|
||||
selectedChoice = $lastChoice;
|
||||
})
|
||||
.click();
|
||||
|
||||
cy.get('[data-test-hook=add-items-disabled]')
|
||||
.find('.choices__list--multiple .choices__item')
|
||||
.last()
|
||||
.should($item => {
|
||||
expect($item.text()).to.not.contain(selectedChoice.text());
|
||||
});
|
||||
.should('not.be.visible');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -335,31 +314,10 @@ describe('Choices - select multiple', () => {
|
|||
});
|
||||
|
||||
describe('on click', () => {
|
||||
it('opens choice dropdown', () => {
|
||||
it('does not opens choice dropdown', () => {
|
||||
cy.get('[data-test-hook=disabled-via-attr]')
|
||||
.find('.choices__list--dropdown')
|
||||
.should('be.visible');
|
||||
});
|
||||
});
|
||||
|
||||
describe('attempting to select choice', () => {
|
||||
let selectedChoice;
|
||||
|
||||
it('does not select choice', () => {
|
||||
cy.get('[data-test-hook=disabled-via-attr]')
|
||||
.find('.choices__list--dropdown .choices__item')
|
||||
.last()
|
||||
.then($lastChoice => {
|
||||
selectedChoice = $lastChoice;
|
||||
})
|
||||
.click();
|
||||
|
||||
cy.get('[data-test-hook=disabled-via-attr]')
|
||||
.find('.choices__list--multiple .choices__item')
|
||||
.last()
|
||||
.should($item => {
|
||||
expect($item.text()).to.not.contain(selectedChoice.text());
|
||||
});
|
||||
.should('not.be.visible');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -240,10 +240,10 @@ describe('Choices - select one', () => {
|
|||
});
|
||||
|
||||
describe('on click', () => {
|
||||
it('opens choice dropdown', () => {
|
||||
it('does not open choice dropdown', () => {
|
||||
cy.get('[data-test-hook=add-items-disabled]')
|
||||
.find('.choices__list--dropdown')
|
||||
.should('be.visible');
|
||||
.should('not.be.visible');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1406,7 +1406,7 @@ class Choices {
|
|||
|
||||
_onClick({ target }) {
|
||||
if (this.containerOuter.element.contains(target)) {
|
||||
if (!this.dropdown.isActive) {
|
||||
if (!this.dropdown.isActive && !this.containerOuter.isDisabled) {
|
||||
if (this._isTextElement) {
|
||||
if (document.activeElement !== this.input.element) {
|
||||
this.input.focus();
|
||||
|
|
Loading…
Reference in a new issue