Skip to content

Commit

Permalink
Fix filter box being duplicated on browser back
Browse files Browse the repository at this point in the history
Fixes #3570
  • Loading branch information
mshibuya committed Nov 23, 2022
1 parent d313a69 commit c6b1893
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions spec/integration/widgets/filter_box_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@
end
end

it 'does not cause duplication when using browser back' do
RailsAdmin.config Player do
field :name
end

visit index_path(model_name: 'player', f: {name: {'1' => {v: 'a'}}})
find(%([href$="/admin/player/export"])).click
is_expected.to have_content 'Export Players'
page.go_back
is_expected.to have_content 'List of Players'
expect(all(:css, '#filters_box div.filter').count).to eq 1
end

describe 'for boolean field' do
before do
RailsAdmin.config FieldTest do
Expand Down
2 changes: 1 addition & 1 deletion src/rails_admin/filter-box.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ import flatpickr from "flatpickr";
}

var filterContainerId = field_name + "-" + index + "-filter-container";
$("p#" + filterContainerId).remove();
$("#" + filterContainerId).remove();

var $content = $("<div>")
.attr("id", filterContainerId)
Expand Down

0 comments on commit c6b1893

Please sign in to comment.