Merge pull request #9954 from nextcloud/search-form-preventdefaults

Prevent search form submit
This commit is contained in:
Morris Jobke 2018-06-21 23:37:14 +02:00 committed by GitHub
commit 7ab0335eaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -86,15 +86,19 @@
// Register input event
document
.getElementById('searchbox')
.addEventListener('input', _.debounce(this.search, 500), true);
.addEventListener('input', _.debounce(self.search, 500), true);
document
.querySelector('form.searchbox')
.addEventListener('submit', _.debounce(this.search, 500), true);
.addEventListener('submit', function(event) {
// Avoid form submit
event.preventDefault();
_.debounce(self.search, 500);
}, true);
// Register reset
document
.querySelector('form.searchbox')
.addEventListener('reset', _.debounce(this.reset, 500), true);
.addEventListener('reset', _.debounce(self.reset, 500), true);
// Register esc key shortcut reset if focused
document.addEventListener('keyup', function(event) {