diff --git a/addons/web/static/src/js/views/kanban/kanban_column.js b/addons/web/static/src/js/views/kanban/kanban_column.js index e17b77aa44f..80d48a78774 100644 --- a/addons/web/static/src/js/views/kanban/kanban_column.js +++ b/addons/web/static/src/js/views/kanban/kanban_column.js @@ -141,14 +141,12 @@ var KanbanColumn = Widget.extend({ return; } var self = this; - this.quickCreateWidget = new RecordQuickCreate(this, { - width: this.records.length ? this.records[0].$el.innerWidth() : this.$el.width() - 8, - defaultName: this.data.getContext().default_name, - }); + var width = this.records.length ? this.records[0].$el.innerWidth() : this.$el.width() - 8; + this.quickCreateWidget = new RecordQuickCreate(this, width); this.quickCreateWidget.insertAfter(this.$header); this.quickCreateWidget.$el.focusout(function () { - var hasFocus = (self.quickCreateWidget.$(':focus').length > 0); - if (! hasFocus && self.quickCreateWidget) { + var taskName = self.quickCreateWidget.$('[type=text]')[0].value; + if (!taskName && self.quickCreateWidget) { self._cancelQuickCreate(); } }); diff --git a/addons/web/static/tests/views/kanban_tests.js b/addons/web/static/tests/views/kanban_tests.js index b2b84ff00d5..8fa1fc6d2d5 100644 --- a/addons/web/static/tests/views/kanban_tests.js +++ b/addons/web/static/tests/views/kanban_tests.js @@ -323,7 +323,7 @@ QUnit.module('Views', { }); QUnit.test('quick create in grouped mode', function (assert) { - assert.expect(6); + assert.expect(8); var nbRecords = 4; var kanban = createView({ @@ -354,10 +354,22 @@ QUnit.module('Views', { assert.strictEqual(kanban.$('.o_kanban_quick_create').length, 0, "should have destroyed the quick create element"); + //click to add and element and focus out the blank input, should cancel the quick creation + kanban.$('.o_kanban_header .o_kanban_quick_add i').first().click(); + $quickCreate = kanban.$('.o_kanban_quick_create'); + $quickCreate.find('input').blur(); + assert.strictEqual(kanban.$('.o_kanban_quick_create').length, 0, + "Blur should have destroyed the quick create element"); + // click to really add an element kanban.$('.o_kanban_header .o_kanban_quick_add i').first().click(); $quickCreate = kanban.$('.o_kanban_quick_create'); $quickCreate.find('input').val('new partner'); + $quickCreate.find('input').blur(); + + // When focus out the input containing value, should not delete the Quick Creation + assert.strictEqual(kanban.$('.o_kanban_quick_create').length, 1, + "Blur should not have destroyed the quick create element"); nbRecords = 5; $quickCreate.find('button.o_kanban_add').click();