diff --git a/cypress/e2e/disabled-fieldset.cy.js b/cypress/e2e/disabled-fieldset.cy.js new file mode 100644 index 000000000..e4e74e287 --- /dev/null +++ b/cypress/e2e/disabled-fieldset.cy.js @@ -0,0 +1,22 @@ +describe('A select inside a disabled fieldset', () => { + it('preserves the value when the fieldset becomes disabled with the menu open', () => { + cy.visit('/tests/index.html'); + cy.window().then(({ $ }) => { + $('body').append(` +
+ `); + $('#project').selectpicker({ container: 'body' }); + }); + + cy.get('button[data-id="project"]').click(); + cy.get('#project-fieldset').invoke('prop', 'disabled', true); + cy.contains('.bs-container .dropdown-item', 'Beta').click(); + + cy.get('#project').should('have.value', 'Alpha'); + }); +}); diff --git a/js/bootstrap-select.js b/js/bootstrap-select.js index e9e413785..7d0b10882 100644 --- a/js/bootstrap-select.js +++ b/js/bootstrap-select.js @@ -2656,7 +2656,7 @@ }, isDisabled: function () { - return this.$element[0].disabled; + return this.$element.is(':disabled'); }, checkDisabled: function () {