From feb2a15edc0468d70219d8bffe3691e090135bd0 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Tue, 30 Oct 2018 22:04:08 +0000 Subject: [PATCH] Disable at a later stage of intialising --- .travis.yml | 2 +- src/scripts/choices.js | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7a1cbc4..93d7b08 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,5 +8,5 @@ install: - npm install script: - npm run test:unit - - npm run test:e2e - npm run coverage + - npm run test:e2e diff --git a/src/scripts/choices.js b/src/scripts/choices.js index e1ae4ca..03f1c11 100644 --- a/src/scripts/choices.js +++ b/src/scripts/choices.js @@ -178,6 +178,7 @@ class Choices { this._createTemplates(); this._createElements(); this._createStructure(); + // Set initial state (We need to clone the state because some reducers // modify the inner objects properties in the state) 🤢 this._initialState = cloneObject(this._store.state); @@ -185,6 +186,14 @@ class Choices { this._render(); this._addEventListeners(); + const shouldDisable = + !this.config.addItems || + this.passedElement.element.hasAttribute('disabled'); + + if (shouldDisable) { + this.disable(); + } + this.initialised = true; const { callbackOnInit } = this.config; @@ -1830,13 +1839,6 @@ class Choices { this.input.setWidth(true); } - if ( - !this.config.addItems || - this.passedElement.element.hasAttribute('disabled') - ) { - this.disable(); - } - this.containerOuter.element.appendChild(this.containerInner.element); this.containerOuter.element.appendChild(this.dropdown.element); this.containerInner.element.appendChild(this.itemList.element);