Add Ctrl + Enter support

This commit is contained in:
Özenç Bilgili 2020-05-19 00:27:03 +03:00
parent 7e1168c34f
commit 98f54d5832

View File

@ -250,7 +250,7 @@ const $ = {
case 9: case 9:
return shift ? 's-tab' : 'tab'; return shift ? 's-tab' : 'tab';
case 13: case 13:
return 'enter'; return ctrl ? 'c-enter' : 'enter';
case 16: case 16:
return 'shift'; return 'shift';
case 17: case 17:
@ -839,6 +839,7 @@ class Form {
this._registerEvents(); this._registerEvents();
this._loadQueryParam(); this._loadQueryParam();
this.invert(); this.invert();
this.isCtrlEnter = false;
} }
hide() { hide() {
@ -913,6 +914,8 @@ class Form {
case 'escape': case 'escape':
this.hide(); this.hide();
return; return;
case 'c-enter':
this.isCtrlEnter = true;
} }
this.show(); this.show();
@ -952,9 +955,10 @@ class Form {
_submitForm(e) { _submitForm(e) {
if (e) e.preventDefault(); if (e) e.preventDefault();
const query = this._inputEl.value; let query = this._inputEl.value;
if (this._suggester) this._suggester.success(query); if (this._suggester) this._suggester.success(query);
this.hide(); this.hide();
if (this.isCtrlEnter) query += '.com';
this._redirect(this._parseQuery(query).redirect); this._redirect(this._parseQuery(query).redirect);
} }