mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Allow the use of the tab key to select options in combo boxes. Fixes #1251
This commit is contained in:
parent
5690dfda16
commit
4c2020cdc7
@ -234,20 +234,25 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
|
||||
id: 'cltype', label:'{{ _('Data type') }}',
|
||||
cell: Backgrid.Extension.NodeAjaxOptionsCell.extend({
|
||||
exitEditMode: function(e) {
|
||||
var self = this;
|
||||
this.$select.off('blur', this.exitEditMode);
|
||||
this.$select.select2('close');
|
||||
this.$el.removeClass('editor');
|
||||
// Once user have selected a value
|
||||
// we can shift to next cell if it is editable
|
||||
var el_length_cell = this.$el.next();
|
||||
if(el_length_cell && el_length_cell.hasClass('editable') && e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
var command = new Backgrid.Command({key: "Tab", keyCode: 9, which: 9});
|
||||
this.model.trigger("backgrid:edited", this.model, this.column,
|
||||
command);
|
||||
el_length_cell.focus();
|
||||
}
|
||||
// Add delay so that Select2 cell tab event is captured
|
||||
// first before triggerring backgrid:edited event.
|
||||
setTimeout(function() {
|
||||
if(el_length_cell && el_length_cell.hasClass('editable') && e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
var command = new Backgrid.Command({key: "Tab", keyCode: 9, which: 9});
|
||||
self.model.trigger("backgrid:edited", self.model, self.column,
|
||||
command);
|
||||
el_length_cell.focus();
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
}),
|
||||
type: 'text', disabled: 'inSchemaWithColumnCheck',
|
||||
|
@ -1851,7 +1851,7 @@
|
||||
render: function() {
|
||||
|
||||
if(this.$sel && this.$sel.select2) {
|
||||
this.$sel.select2('destroy')
|
||||
this.$sel.select2('destroy');
|
||||
}
|
||||
|
||||
var field = _.defaults(this.field.toJSON(), this.defaults),
|
||||
@ -1916,6 +1916,17 @@
|
||||
*/
|
||||
this.$sel = this.$el.find("select").select2(select2Opts);
|
||||
|
||||
// Select the highlighted item on Tab press.
|
||||
if (this.$sel) {
|
||||
this.$sel.data('select2').on("keypress", function(ev) {
|
||||
var self = this;
|
||||
if (ev.which === 9) { // keycode 9 is for TAB key
|
||||
ev.preventDefault();
|
||||
self.trigger('results:select', {});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.updateInvalid();
|
||||
|
||||
return this;
|
||||
|
@ -538,7 +538,18 @@
|
||||
this.delegateEvents();
|
||||
|
||||
// Initialize select2 control.
|
||||
this.$select.select2(select2_opts);
|
||||
this.$sel = this.$select.select2(select2_opts);
|
||||
|
||||
// Select the highlighted item on Tab press.
|
||||
if (this.$sel) {
|
||||
this.$sel.data('select2').on("keypress", function(ev) {
|
||||
var self = this;
|
||||
if (ev.which === 9) { // keycode 9 is for TAB key
|
||||
self.trigger('results:select', {});
|
||||
ev.preventDefault();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user