From 9523a3312f4c4f23ddfc89393aeb5921d1b64f52 Mon Sep 17 00:00:00 2001 From: Evan Kuchar Date: Tue, 6 Mar 2018 16:32:20 -0800 Subject: [PATCH] Avoid duplication of filters on back Bug: filters are duplicated when using back button Repro steps: Using Chrome, visit a list page, apply a filter, click into an element, click back button Using these steps, I see a duplicated filter. RailsAdmin is appending the filters regardless of whether or not they are there. This fixes that by adding an id to each filter based on the name and index. Before appending, it removes any filters with that id. --- app/assets/javascripts/rails_admin/ra.filter-box.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/assets/javascripts/rails_admin/ra.filter-box.js b/app/assets/javascripts/rails_admin/ra.filter-box.js index 889e482eaf..dc655541c6 100644 --- a/app/assets/javascripts/rails_admin/ra.filter-box.js +++ b/app/assets/javascripts/rails_admin/ra.filter-box.js @@ -157,7 +157,11 @@ break; } + var filterContainerId = field_name + '-' + index + '-filter-container'; + $('p#' + filterContainerId).remove(); + var $content = $('

') + .attr('id', filterContainerId) .addClass('filter form-search') .append( $('')