Remove pointless comments + minor tidying

This commit is contained in:
Josh Johnson 2018-05-28 14:18:44 +01:00
parent 804a4a442b
commit 39beb20245

View file

@ -1000,8 +1000,6 @@ class Choices {
this.showDropdown(true); this.showDropdown(true);
} }
this.config.searchEnabled = this.config.searchEnabled;
const onAKey = () => { const onAKey = () => {
// If CTRL + A or CMD + A have been pressed and there are items to select // If CTRL + A or CMD + A have been pressed and there are items to select
if (ctrlDownKey && hasItems) { if (ctrlDownKey && hasItems) {
@ -1185,7 +1183,6 @@ class Choices {
// If user has removed value... // If user has removed value...
if ((keyCode === backKey || keyCode === deleteKey) && !target.value) { if ((keyCode === backKey || keyCode === deleteKey) && !target.value) {
// ...and it is a multiple select input, activate choices (if searching)
if (!this._isTextElement && this._isSearching) { if (!this._isTextElement && this._isSearching) {
this._isSearching = false; this._isSearching = false;
this._store.dispatch(activateChoices(true)); this._store.dispatch(activateChoices(true));
@ -1210,11 +1207,12 @@ class Choices {
// If a user tapped within our container... // If a user tapped within our container...
if (this._wasTap === true && this.containerOuter.element.contains(target)) { if (this._wasTap === true && this.containerOuter.element.contains(target)) {
// ...and we aren't dealing with a single select box, show dropdown/focus input // ...and we aren't dealing with a single select box, show dropdown/focus input
if (
(target === this.containerOuter.element || const containerWasTarget =
target === this.containerInner.element) && target === this.containerOuter.element ||
!this._isSelectOneElement target === this.containerInner.element;
) {
if (containerWasTarget && !this._isSelectOneElement) {
if (this._isTextElement) { if (this._isTextElement) {
// If text element, we only want to focus the input // If text element, we only want to focus the input
this.input.focus(); this.input.focus();
@ -1285,8 +1283,7 @@ class Choices {
this.showDropdown(true); this.showDropdown(true);
} else { } else {
this.showDropdown(); this.showDropdown();
// code smell this.containerOuter.focus(); // code smell 🤢
this.containerOuter.focus();
} }
} else if ( } else if (
this._isSelectOneElement && this._isSelectOneElement &&
@ -1321,7 +1318,6 @@ class Choices {
'select-one': () => { 'select-one': () => {
this.containerOuter.addFocusState(); this.containerOuter.addFocusState();
if (target === this.input.element) { if (target === this.input.element) {
// Show dropdown if it isn't already showing
this.showDropdown(); this.showDropdown();
} }
}, },
@ -1349,9 +1345,7 @@ class Choices {
const blurActions = { const blurActions = {
text: () => { text: () => {
if (target === this.input.element) { if (target === this.input.element) {
// Remove the focus state
this.containerOuter.removeFocusState(); this.containerOuter.removeFocusState();
// De-select any highlighted items
if (hasHighlightedItems) { if (hasHighlightedItems) {
this.unhighlightAll(); this.unhighlightAll();
} }
@ -1370,10 +1364,8 @@ class Choices {
}, },
'select-multiple': () => { 'select-multiple': () => {
if (target === this.input.element) { if (target === this.input.element) {
// Remove the focus state
this.containerOuter.removeFocusState(); this.containerOuter.removeFocusState();
this.hideDropdown(); this.hideDropdown();
// De-select any highlighted items
if (hasHighlightedItems) { if (hasHighlightedItems) {
this.unhighlightAll(); this.unhighlightAll();
} }
@ -1959,10 +1951,8 @@ class Choices {
const { activeGroups, activeChoices } = this._store; const { activeGroups, activeChoices } = this._store;
let choiceListFragment = document.createDocumentFragment(); let choiceListFragment = document.createDocumentFragment();
// Clear choices
this.choiceList.clear(); this.choiceList.clear();
// Scroll back to top of choices list
if (this.config.resetScrollPosition) { if (this.config.resetScrollPosition) {
this.choiceList.scrollToTop(); this.choiceList.scrollToTop();
} }
@ -2054,6 +2044,5 @@ class Choices {
} }
Choices.userDefaults = {}; Choices.userDefaults = {};
// We cannot export default here due to Webpack: https://github.com/webpack/webpack/issues/3929 // We cannot export default here due to Webpack: https://github.com/webpack/webpack/issues/3929
module.exports = Choices; module.exports = Choices;