[FIX] web: fix crash keyboard related crash in graph view

Before this fix, when going on the graph view from the dashboard view (
using the fullscreen button on dashboard), the focus is on the search
input, hitting the tab key creates a crash.

This fix gives a default implementation of giveFocus to the
abstractrenderer so there is no crash.
This commit is contained in:
Vincent Schippefilt
2018-04-25 09:11:44 +02:00
parent ec5e27bb7c
commit de72b13064
3 changed files with 21 additions and 7 deletions
@@ -66,6 +66,11 @@ return Widget.extend({
*/
getLocalState: function () {
},
/**
* Order to focus to be given to the content of the current view
*/
giveFocus: function () {
},
/**
* This is the reverse operation from getLocalState. With this method, we
* expect the renderer to restore all DOM state, if it is relevant.
@@ -135,13 +135,6 @@ var BasicRenderer = AbstractRenderer.extend({
dom.setSelectionRange(field.getFocusableElement().get(0), {start: offset, end: offset});
}
},
/**
* Order to focus to be given to the content of the current view
*/
giveFocus:function() {
},
//--------------------------------------------------------------------------
// Private
//--------------------------------------------------------------------------
@@ -602,6 +602,22 @@ QUnit.module('Views', {
done();
});
});
QUnit.test('graph view crash when moving from search view using Down key', function (assert) {
assert.expect(1);
var graph = createView({
View: GraphView,
model: "foo",
data: this.data,
arch: '<graph string="Partners" type="pie">' +
'<field name="bar"/>' +
'</graph>',
});
graph.renderer.giveFocus();
assert.ok(true,"should not generate any error");
graph.destroy();
});
});
});