Commit 2bbc44cb authored by Clement Ho's avatar Clement Ho

Refactor itemClicked

parent 6c811d47
...@@ -20,15 +20,10 @@ ...@@ -20,15 +20,10 @@
} }
itemClicked(e) { itemClicked(e) {
const dataValueSet = this.setDataValueIfSelected(e.detail.selected); super.itemClicked(e, (selected) => {
if (!dataValueSet) {
const title = e.detail.selected.querySelector('.js-data-value').innerText.trim(); const title = e.detail.selected.querySelector('.js-data-value').innerText.trim();
const name = `${this.symbol}${this.getEscapedText(title)}`; return `${this.symbol}${this.getEscapedText(title)}`;
gl.FilteredSearchDropdownManager.addWordToInput(this.getSelectedText(name)); });
}
this.dismissDropdown(!dataValueSet);
} }
getEscapedText(text) { getEscapedText(text) {
......
...@@ -23,14 +23,9 @@ ...@@ -23,14 +23,9 @@
} }
itemClicked(e) { itemClicked(e) {
const dataValueSet = this.setDataValueIfSelected(e.detail.selected); super.itemClicked(e, (selected) => {
return selected.querySelector('.dropdown-light-content').innerText.trim();
if (!dataValueSet) { });
const username = e.detail.selected.querySelector('.dropdown-light-content').innerText.trim();
gl.FilteredSearchDropdownManager.addWordToInput(this.getSelectedText(username));
}
this.dismissDropdown(!dataValueSet);
} }
renderContent(forceShowList = false) { renderContent(forceShowList = false) {
......
...@@ -35,8 +35,15 @@ ...@@ -35,8 +35,15 @@
return lastWordIndex === -1 ? selectedToken : selectedToken.slice(lastWord.length); return lastWordIndex === -1 ? selectedToken : selectedToken.slice(lastWord.length);
} }
itemClicked(e) { itemClicked(e, getValueFunction) {
// Overridden by dropdown sub class const dataValueSet = this.setDataValueIfSelected(e.detail.selected);
if (!dataValueSet) {
const value = getValueFunction(e.detail.selected)
gl.FilteredSearchDropdownManager.addWordToInput(this.getSelectedText(value));
}
this.dismissDropdown();
} }
renderContent(forceShowList = false) { renderContent(forceShowList = false) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment