Fix accessibility issue for Datetime cell in backgrid. Fixes #4508

This commit is contained in:
Murtuza Zabuawala 2019-07-25 17:54:24 +05:30 committed by Akshay Joshi
parent 136bb412a1
commit 108af5c10b
2 changed files with 23 additions and 7 deletions

View File

@ -18,3 +18,4 @@ Bug fixes
*********
| `Issue #4490 <https://redmine.postgresql.org/issues/4490>`_ - Fix accessibility issue for checkbox in IE11.
| `Issue #4508 <https://redmine.postgresql.org/issues/4508>`_ - Fix accessibility issue for Datetime cell in backgrid.

View File

@ -1755,6 +1755,7 @@ define([
},
},
});
this.tabKeyPress = false;
this.$el.datetimepicker(options);
this.$el.datetimepicker('show');
this.picker = this.$el.data('DateTimePicker');
@ -1762,27 +1763,41 @@ define([
events: {
'hide.datetimepicker': 'closeIt',
'focusout':'closeIt',
'keydown': 'keydownHandler',
},
closeIt: function(ev) {
keydownHandler: function(event) {
// If Tab key pressed from Cell and not from Datetime picker element
// then we should trigger edited event so that we can goto next cell
let self = this;
let tabKeyPressed = true;
if (event.keyCode === 9 && self.el === event.target) {
self.closeIt(event, tabKeyPressed);
}
},
closeIt: function(ev, isTabKeyPressed) {
if (this.is_closing || this.tabKeyPress)
return;
this.is_closing = true;
this.tabKeyPress = isTabKeyPressed;
var formatter = this.formatter,
model = this.model,
column = this.column,
val = this.$el.val(),
newValue = formatter.toRaw(val, model);
if (this.is_closing)
return;
this.is_closing = true;
this.$el.datetimepicker('destroy');
this.is_closing = false;
var command = new Backgrid.Command(ev);
if (_.isUndefined(newValue)) {
model.trigger('backgrid:error', model, column, val);
} else {
model.set(column.get('name'), newValue);
let command = new Backgrid.Command(ev);
setTimeout(() => {
model.trigger('backgrid:edited', model, column, command);
}, 20);
}
},
});