avo icon indicating copy to clipboard operation
avo copied to clipboard

Filters showing as active when they shouldn't be

Open rctneil opened this issue 1 year ago • 4 comments
trafficstars

Describe the bug

A basic filter is showing that a filter is applied when clearly none of the options are selected. This happens after applying and then disabling a filter. The table view of records updates with the no longer filtered records but the filter button still says a filter is active.

Screenshot 2023-12-20 at 22 03 16

My filters are:

class Avo::Filters::Logo1 < Avo::Filters::BooleanFilter
  self.name = "Logos"
  # self.visible = -> do
  #   true
  # end

  def apply(request, query, values)
    return query if values['logo'] && values['no_logo']

    if values['logo']
      query = query.with_logo1
    elsif values['no_logo']
      query = query.without_logo1
    end

    query
  end

  def options
    {
      logo: "Have Logos",
      no_logo: "Do not have Logos"
    }
  end
end
class Avo::Filters::Milestones < Avo::Filters::BooleanFilter
  self.name = "Milestones"
  # self.visible = -> do
  #   true
  # end

  def apply(request, query, values)
    return query if values['milestones'] && values['not_milestones']

    if values['milestones']
      query = query.milestones
    elsif values['not_milestones']
      query = query.where.not(id: Coaster.milestones)
    end

    query
  end

  def options
    {
      milestones: "Milestones",
      not_milestones: "Not Milestones"
    }
  end
end

and

class Avo::Filters::Soundtrack1 < Avo::Filters::BooleanFilter
  self.name = "Soundtracks"
  # self.visible = -> do
  #   true
  # end

  def apply(request, query, values)
    return query if values['soundtrack'] && values['no_soundtracks']

    if values['soundtracks']
      query = query.with_soundtrack1
    elsif values['not_soundtracks']
      query = query.without_soundtrack1
    end

    query
  end

  def options
    {
      soundtracks: "Have Soundtracks",
      no_soundtracks: "Do not have Soundtracks"
    }
  end
end

rctneil avatar Dec 20 '23 22:12 rctneil

What do you have in your URL when that is visible? Also, do any of your filters use the default method?

adrianthedev avatar Jan 06 '24 21:01 adrianthedev

@adrianthedev Sorry for the delay in reply. Things have been super hectic recently.

When it says a filter is applied but it actually isn't, my URL looks like:

http://localhost:3000/avo/resources/coasters?page=1&filters=eyJBdm86OkZpbHRlcnM6OkxvZ28xIjp7ImxvZ28iOmZhbHNlLCJub19sb2dvIjpmYWxzZX19

No, none of my Filters use the default method.

rctneil avatar Jan 17 '24 09:01 rctneil

This issue has been marked as stale because there was no activity for the past 15 days.

github-actions[bot] avatar Feb 04 '24 01:02 github-actions[bot]

This issue has been marked as stale because there was no activity for the past 15 days.

github-actions[bot] avatar Feb 29 '24 01:02 github-actions[bot]

Closing this because there was no activity for the past 15 days. Feel free to reopen if new information pops up ✌️

github-actions[bot] avatar Mar 15 '24 01:03 github-actions[bot]

This issue has been marked as stale because there was no activity for the past 15 days.

github-actions[bot] avatar Mar 31 '24 01:03 github-actions[bot]

@rctneil are you able to share a reproduction repository?

Paul-Bob avatar Apr 01 '24 09:04 Paul-Bob

This issue has been marked as stale because there was no activity for the past 15 days.

github-actions[bot] avatar Apr 17 '24 01:04 github-actions[bot]

Closing this because there was no activity for the past 15 days. Feel free to reopen if new information pops up ✌️

github-actions[bot] avatar May 02 '24 01:05 github-actions[bot]