From 58a0a84c3817de94f1b108697b23b57f78d67425 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Fri, 29 Jun 2018 16:23:28 +0200 Subject: [PATCH] [2.1.x] Fixed #29536 -- Fixed SelectFilter2.js resizing to make boxes have equal height. Thanks Tim Graham for the review. Backport of a5f139236f930df06ae0642507530ca98081e2a9 from master. --- django/contrib/admin/static/admin/js/SelectFilter2.js | 4 ++-- js_tests/admin/SelectFilter2.test.js | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/django/contrib/admin/static/admin/js/SelectFilter2.js b/django/contrib/admin/static/admin/js/SelectFilter2.js index 52471d9472..b6bcda0c3c 100644 --- a/django/contrib/admin/static/admin/js/SelectFilter2.js +++ b/django/contrib/admin/static/admin/js/SelectFilter2.js @@ -164,8 +164,8 @@ Requires jQuery, core.js, and SelectBox.js. if (!is_stacked) { // In horizontal mode, give the same height to the two boxes. - var j_from_box = $(from_box); - var j_to_box = $(to_box); + var j_from_box = $('#' + field_id + '_from'); + var j_to_box = $('#' + field_id + '_to'); var resize_filters = function() { j_to_box.height($(filter_p).outerHeight() + j_from_box.outerHeight()); }; if (j_from_box.outerHeight() > 0) { resize_filters(); // This fieldset is already open. Resize now. diff --git a/js_tests/admin/SelectFilter2.test.js b/js_tests/admin/SelectFilter2.test.js index c000584f48..c6b3000465 100644 --- a/js_tests/admin/SelectFilter2.test.js +++ b/js_tests/admin/SelectFilter2.test.js @@ -11,6 +11,10 @@ QUnit.test('init', function(assert) { SelectFilter.init('id', 'things', 0); assert.equal($('.selector-available h2').text().trim(), "Available things"); assert.equal($('.selector-chosen h2').text().trim(), "Chosen things"); + assert.equal( + $('.selector-available select').outerHeight() + $('.selector-filter').outerHeight(), + $('.selector-chosen select').height() + ); assert.equal($('.selector-chooseall').text(), "Choose all"); assert.equal($('.selector-add').text(), "Choose"); assert.equal($('.selector-remove').text(), "Remove");