Skip to content
Permalink
Browse files

[FIX] web: correctly manage attach-detach callback

d06e67e introduces tools to use owl renderer
for a view. However, on_attach_callback and on_detach_callback were not
called on super (AbstractController), so not applied to the controlPanel
and searchPanel.
This commit fixes this issue

Task-ID 2171436

closes #43165

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
  • Loading branch information
pro-odoo committed Jan 13, 2020
1 parent a44d772 commit 1900abf23331441c3551fc1a9478294f620e2a69
@@ -4,12 +4,6 @@ odoo.define('web.ControllerAdapter', function (require) {
var AbstractController = require('web.AbstractController');

var ControllerAdapter = AbstractController.extend({
on_attach_callback: function () {
this.renderer.__callMounted();
},
on_detach_callback: function () {
this.renderer.__callWillUnmount();
},

/**
* @override
@@ -39,6 +39,14 @@ odoo.define('web.RendererWrapper', function (require) {
}
}

on_attach_callback() {
this.__callMounted();
}

on_detach_callback() {
this.__callWillUnmount();
}

setParent() { }

getLocalState() { }
@@ -121,5 +121,21 @@ QUnit.module("Views", {
assert.verifySteps(["destroy"]);

});

QUnit.test('Correctly set focus to search panel with Owl Renderer', async function (assert) {
assert.expect(1);

class Renderer extends AbstractRenderer { }
Renderer.template = xml`<div>Test</div>`;

var view = await createView({
View: getOwlView(Renderer, "test"),
data: this.data,
model: "test_model",
arch: "<test/>",
});
assert.hasClass(document.activeElement, "o_searchview_input");
view.destroy();
});
});
});

0 comments on commit 1900abf

Please sign in to comment.
You can’t perform that action at this time.