Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate filters on history nav #2622

Conversation

bartonmcguire
Copy link

There is a bug in which index page filters are duplicated when navigating back or forward in browser history. It's not a total show-stopper, but it's been bothering some of my users. And it is obviously incorrect/buggy behavior.

Repro steps:

  1. Navigate to a RailsAdmin resource index.
  2. Filter the index by some criteria (ex: 'Created At' => 'Is present')
  3. Click "refresh" to apply the filter
  4. Navigate somewhere within RailsAdmin (ex: click to "edit" a record in the index)
  5. Navigate "back" via your browsers back button to the index.

Notice that there are now two "Created At" filters. Navigate forward and back again, now there are three... yikes!

This is because when navigating back the previously rendered filters are still on the page, but the inline script to append new filters gets run again.

The fix that I've come up with is to create an alternative function, $.filters.init, which is called inline instead. init simply checks whether any filters have been rendered already, and only builds filters for the array of options it is passed if they have not.

I've updated specs that test the view helper construction of the inline script. However, I found no tests anywhere that cover the behavior of $.filters, so I did not add tests for $.filters.init.

@bartonmcguire
Copy link
Author

This build is failing during gem installation - but clearly the diff shouldn't affect this. It looks like builds for other recent and unrelated pull requests are failing for the same reason - leading me to believe that my diff does not introduce the issue. Does master still successfully build? Has your CI settings/config changed since its last successful build?

@cec
Copy link

cec commented Aug 14, 2017

I can confirm the reported issue, which many of our users are finding to be troublesome.
@mshibuya @bbenezech I apologize for the direct mention as I know that u guys are very busy, but I'd like to know if u plan to address this and possibly backport it to earlier versions of the gem

@mshibuya
Copy link
Member

mshibuya commented May 4, 2018

Fixed by #2998.

@mshibuya mshibuya closed this May 4, 2018
@bartonmcguire bartonmcguire deleted the duplicate-filters-on-history-nav branch March 8, 2019 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants