Removing loading text flag regardless of whether there is a placeholder set

This commit is contained in:
Josh Johnson 2016-09-24 10:52:05 +01:00
parent 4c25b105d3
commit cd0bb9d45f
2 changed files with 13 additions and 11 deletions

View file

@ -159,7 +159,8 @@ export default class Choices {
this.wasTap = true; this.wasTap = true;
// Cutting the mustard // Cutting the mustard
const cuttingTheMustard = 'querySelector' in document && 'addEventListener' in document && 'classList' in document.createElement('div'); const cuttingTheMustard = 'querySelector' in document && 'addEventListener' in document && 'classList' in document.createElement(
'div');
if (!cuttingTheMustard) console.error('Choices: Your browser doesn\'t support Choices'); if (!cuttingTheMustard) console.error('Choices: Your browser doesn\'t support Choices');
// Input type check // Input type check
@ -662,11 +663,9 @@ export default class Choices {
// Remove loading states/text // Remove loading states/text
this.containerOuter.classList.remove(this.config.classNames.loadingState); this.containerOuter.classList.remove(this.config.classNames.loadingState);
if (this.passedElement.type === 'select-multiple') { if (this.passedElement.type === 'select-multiple') {
const placeholder = this.config.placeholder ? this.config.placeholderValue || this.passedElement.getAttribute('placeholder') : const placeholder = this.config.placeholder ? this.config.placeholderValue || this.passedElement.getAttribute(
false; 'placeholder') : false;
if (placeholder) { this.input.placeholder = placeholder || '';
this.input.placeholder = placeholder;
}
} }
// Add each result as a choice // Add each result as a choice
@ -723,7 +722,8 @@ export default class Choices {
this._triggerChange(itemToRemove.value); this._triggerChange(itemToRemove.value);
if (this.passedElement.type === 'select-one') { if (this.passedElement.type === 'select-one') {
const placeholder = this.config.placeholder ? this.config.placeholderValue || this.passedElement.getAttribute('placeholder') : false; const placeholder = this.config.placeholder ? this.config.placeholderValue || this.passedElement.getAttribute('placeholder') :
false;
if (placeholder) { if (placeholder) {
const placeholderItem = this._getTemplate('placeholder', placeholder); const placeholderItem = this._getTemplate('placeholder', placeholder);
this.itemList.appendChild(placeholderItem); this.itemList.appendChild(placeholderItem);
@ -1172,7 +1172,8 @@ export default class Choices {
if (this.config.placeholder && (this.config.placeholderValue || this.passedElement.getAttribute('placeholder'))) { if (this.config.placeholder && (this.config.placeholderValue || this.passedElement.getAttribute('placeholder'))) {
// If there is a placeholder, we only want to set the width of the input when it is a greater // If there is a placeholder, we only want to set the width of the input when it is a greater
// length than 75% of the placeholder. This stops the input jumping around. // length than 75% of the placeholder. This stops the input jumping around.
const placeholder = this.config.placeholder ? this.config.placeholderValue || this.passedElement.getAttribute('placeholder') : false; const placeholder = this.config.placeholder ? this.config.placeholderValue || this.passedElement.getAttribute('placeholder') :
false;
if (this.input.value && this.input.value.length >= (placeholder.length / 1.25)) { if (this.input.value && this.input.value.length >= (placeholder.length / 1.25)) {
this.input.style.width = getWidthOfInput(this.input); this.input.style.width = getWidthOfInput(this.input);
} }
@ -1777,7 +1778,8 @@ export default class Choices {
); );
}, },
dropdown: () => { dropdown: () => {
return strToEl(` return strToEl(
`
<div class="${classNames.list} ${classNames.listDropdown}" aria-expanded="false"></div> <div class="${classNames.list} ${classNames.listDropdown}" aria-expanded="false"></div>
`); `);
}, },
@ -2100,4 +2102,4 @@ export default class Choices {
} }
} }
window.Choices = module.exports = Choices; window.Choices = module.exports = Choices;

View file

@ -405,4 +405,4 @@
<script async src='https://www.google-analytics.com/analytics.js'></script> <script async src='https://www.google-analytics.com/analytics.js'></script>
<!-- End Google Analytics --> <!-- End Google Analytics -->
</body> </body>
</html> </html>