From 019979c448744d0e5841358f936c25678c296cbb Mon Sep 17 00:00:00 2001 From: Rui Zhu <60585487+Rui-Zhu1@users.noreply.github.com> Date: Thu, 22 Jun 2023 15:35:15 -0400 Subject: [PATCH] fix: sorting incorrectly after searching (#29) --- lib/sn_filterable/filterable.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/sn_filterable/filterable.rb b/lib/sn_filterable/filterable.rb index c01ced4..4ecbc67 100644 --- a/lib/sn_filterable/filterable.rb +++ b/lib/sn_filterable/filterable.rb @@ -33,9 +33,8 @@ def filter(params:, items: where(nil), default_sort: nil, pagination_enabled: tr filter_params = filter_params(params) sort_params = sort_params(params) other_params = other_params(params, items) - - items = perform_filter(items, filter_params) items, sort_name, reverse_order = perform_sort(items, sort_params, default_sort) + items = perform_filter(items, filter_params) items = items.page(other_params[:page]).per(other_params[:per]) if pagination_enabled Filtered.new(self, items, generate_url_queries(filter_params, sort_params, other_params), sort_name, reverse_order)