Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
e5b061b8
Commit
e5b061b8
authored
Dec 09, 2016
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reposition dropdown when backspace is hit
parent
0eb9f537
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
12 deletions
+33
-12
app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
...avascripts/filtered_search/filtered_search_manager.js.es6
+33
-12
No files found.
app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
View file @
e5b061b8
...
@@ -94,6 +94,7 @@
...
@@ -94,6 +94,7 @@
this.setupMapping();
this.setupMapping();
this.unbindEvents();
document.removeEventListener('page:fetch', this.cleanupWrapper);
document.removeEventListener('page:fetch', this.cleanupWrapper);
}
}
...
@@ -144,12 +145,17 @@
...
@@ -144,12 +145,17 @@
filteredSearchInput.value += hasExistingValue && addSpace ? ` ${word}` : word;
filteredSearchInput.value += hasExistingValue && addSpace ? ` ${word}` : word;
}
}
updateDropdownOffset(key) {
const filterIconPadding = 27;
const offset = gl.text.getTextWidth(this.filteredSearchInput.value, this.font) + filterIconPadding;
this.mapping[key].reference.setOffset(offset);
}
load(key, firstLoad = false) {
load(key, firstLoad = false) {
console.log(`🦄 load ${key} dropdown`);
console.log(`🦄 load ${key} dropdown`);
const glClass = this.mapping[key].gl;
const glClass = this.mapping[key].gl;
const element = this.mapping[key].element;
const element = this.mapping[key].element;
const filterIconPadding = 27;
const dropdownOffset = gl.text.getTextWidth(this.filteredSearchInput.value, this.font) + filterIconPadding;
let forceShowList = false;
let forceShowList = false;
if (!this.mapping[key].reference) {
if (!this.mapping[key].reference) {
...
@@ -165,7 +171,7 @@
...
@@ -165,7 +171,7 @@
forceShowList = true;
forceShowList = true;
}
}
this.
mapping[key].reference.setOffset(dropdownOffset
);
this.
updateDropdownOffset(key
);
this.mapping[key].reference.render(firstLoad, forceShowList);
this.mapping[key].reference.render(firstLoad, forceShowList);
this.currentDropdown = key;
this.currentDropdown = key;
...
@@ -213,17 +219,25 @@
...
@@ -213,17 +219,25 @@
}
}
}
}
// dismissCurrentDropdown() {
// if (this.currentDropdown === 'hint') {
// this.mapping['hint'].hide();
// }
// }
bindEvents() {
bindEvents() {
this.filteredSearchInput.addEventListener('input', this.setDropdown.bind(this));
this.setDropdownWrapper = this.setDropdown.bind(this);
this.checkForEnterWrapper = this.checkForEnter.bind(this);
this.clearSearchWrapper = this.clearSearch.bind(this);
this.checkForBackspaceWrapper = this.checkForBackspace.bind(this);
this.filteredSearchInput.addEventListener('input', this.setDropdownWrapper);
this.filteredSearchInput.addEventListener('input', toggleClearSearchButton);
this.filteredSearchInput.addEventListener('input', toggleClearSearchButton);
this.filteredSearchInput.addEventListener('keydown', this.checkForEnter.bind(this));
this.filteredSearchInput.addEventListener('keydown', this.checkForEnterWrapper);
this.clearSearchButton.addEventListener('click', this.clearSearch.bind(this));
this.filteredSearchInput.addEventListener('keyup', this.checkForBackspaceWrapper);
this.clearSearchButton.addEventListener('click', this.clearSearchWrapper);
}
unbindEvents() {
this.filteredSearchInput.removeEventListener('input', this.setDropdownWrapper);
this.filteredSearchInput.removeEventListener('input', toggleClearSearchButton);
this.filteredSearchInput.removeEventListener('keydown', this.checkForEnterWrapper);
this.filteredSearchInput.removeEventListener('keyup', this.checkForBackspaceWrapper);
this.clearSearchButton.removeEventListener('click', this.clearSearchWrapper);
}
}
clearSearch(e) {
clearSearch(e) {
...
@@ -235,6 +249,13 @@
...
@@ -235,6 +249,13 @@
this.setDropdown();
this.setDropdown();
}
}
checkForBackspace(e) {
if (e.keyCode === 8) {
// Reposition dropdown so that it is aligned with cursor
this.updateDropdownOffset(this.currentDropdown);
}
}
checkForEnter(e) {
checkForEnter(e) {
// Enter KeyCode
// Enter KeyCode
if (e.keyCode === 13) {
if (e.keyCode === 13) {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment