Bulk actions in search results: Checkboxes vanish as new content loads

AI-generated summary

A bug was reported where checkboxes for bulk actions vanish in search results when new content loads via infinite scroll, unlike in category lists where state is preserved. southpaw detailed the issue and steps to reproduce, noting its importance for handling large result sets. Stephen confirmed reproducibility on a specific beta version. venarius identified the root cause in full-page-search.js.es6, where loadMore() resets bulkSelectEnabled, and submitted a PR to fix it. codinghorror questioned the necessity of bulk actions on >50 search results, but southpaw affirmed its occasional but critical utility. sam deployed the fix, noting it resolves the main issue (state loss) but isn’t “100% perfect.” southpaw praised the fix, and sam clarified that “perfect” would involve prompting users when not all results are loaded (e.g., via a modal), though such enhancements aren’t planned for this rare use case. The fix is live and functional, preserving selection state during pagination.

When I try to take bulk actions on search results, the checkboxes vanish every time I hit the bottom of the page and new topics are loaded.

Steps to reproduce:

  1. Perform a search that will return more than 50 results.

  2. Click the image button to select individual topics.

  3. Scroll down to the bottom of the search results so that additional topics load.

  4. Observe that the checkboxes vanish, requiring you to start the selection task anew.

By contrast, when taking bulk action on a topic list in a Category, the checkboxes are preserved as new content is loaded at the bottom of the page.

3 likes

Can repro on 2.3.0.beta3 +115

Has probably something to do with the loadMore() function in the full-page-search.js.es6 controller calling _search(), in which there is this.set("bulkSelectEnabled", false);

It should probably keep its state when page is greater than 1.

Would love to do a PR!

Edit: PR is open :slight_smile:

https://github.com/discourse/discourse/pull/7139

6 likes

This is kind of an unusual scenario. You need to take action on more than 50 search results at once?

Yes. I wouldn’t have stumbled upon the issue had I not needed to take action on a large number of search results.

I don’t need to do it frequently, but when I do need it, it would be nice if it worked the same way as the bulk actions in the Category list.

2 likes

Cool, thanks for the fix @venarius I just deployed it to your site @southpaw and it should be live in 20 mins.

Its not 100% perfect but we no longer losing state which was the big bug here.

6 likes

Thanks for the quick action to get this solved!

I’m not sure what 100% perfect would look like, but this fix is good!

2 likes

I was being a bit vague… we don’t plan to gold plate this, however… if we were to gold plate it…

  1. User clicks “select all”
  2. We detect not everything is loaded, we display something like this (in a modal)

I think its totally fair for me to explain this thing, but yeah we will not be taking pull requests on this rare functionality quite yet.

5 likes

This topic was automatically closed after 29 hours. New replies are no longer allowed.