Bug/Search: All Categories#31
Conversation
public/src/modules/categoryFilter.js All Categories
to :
- Search all categories on entering the search page
- Search all categories after selecting such in the categories
dropdown
|
🚅 Deployed to the nodebb-spring-26-clean-cod-pr-31 environment in Clean Code Team (nodebb)
|
Pull Request Test Coverage Report for Build 21887552135Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
|
nice! |
|
I'll review the code soon |
| const hasRenderedResults = !!$('#results .search-results').length; | ||
| const term = (searchFilters.term || '').trim(); | ||
|
|
||
| if (term && !hasRenderedResults && lastAutoQueryUrl !== currentUrl) { | ||
| lastAutoQueryUrl = currentUrl; | ||
| searchModule.query(searchFilters); | ||
| } |
There was a problem hiding this comment.
was the intention to run search once on load?
Yep, it was.
| $('[component="category/filter/button"]').toggleClass( | ||
| 'active-filter', isActive | ||
| ).find('.filter-label').translateText(labelText); | ||
| $('[component="category/filter/button"]') |
There was a problem hiding this comment.
I thought I fixed that. Good to know.
Edit: rolling back the categoryFilterDropdown seems to have fixed the issue; it seems I was trying to fix the issue that wasn't in that location. Which caused problems.
| let cids = Array.isArray(data.selectedCids) ? data.selectedCids.map(String) : []; | ||
| cids = cids.filter(Boolean).filter(cid => cid !== 'all'); // keep UI form | ||
|
|
||
| ajaxify.data.selectedCids = cids; |
There was a problem hiding this comment.
what does ajaxify.data.selectedCids = cids; do exactly?
There was a problem hiding this comment.
It should update the what is displayed on the screen to hopefully be the [] version (with the checkmark) if it is actually ['all'] because its display is coded up to show All Categories on []
|
code looks good - why not do something like this to ensure at most only one fetch on page load? if (term && firstInit) {
searchModule.query(searchFilters);
firstInit = false;
} |
It depends on the scope - if first init is declared outside of the init function, then it will only default search when you first open the search function, and will not auto search if you open a search page for a second time after having left it (bad behavior). If firstInit is declared in the init, then it loops forever. |
what does this mean exactly? |
So say you try searching for 111, it auto searches. Then you check out some pages on the Nodebb website (leave the search page). |
|
could you provide a video demo of what u mean? I can't seem to replicate that after changing the code to use Screen.Recording.2026-02-08.at.11.52.01.AM.mov |
2026-02-08.11-54-35.mp4 |
|
hmm I see... seems like the issue is that using the search icon sends this query Pressing the actual search button (for the same search term) results in this query The first query returns nothing, while the second one returns the "111" post. perhaps we could consider fixing search behavior on the first endpoint so that it matches the second? (maybe in another pr) |
behavior: adds category all field to all searches even those that may not need a category.
be fixed later. Impact is low.
| schema = context[method].responses['200'].content['application/json'].schema; | ||
| compare(schema, result.body, method.toUpperCase(), path, 'root'); | ||
| } | ||
|
|
There was a problem hiding this comment.
I don't think we're allowed to remove everything here lmao. This removes like all api endpoint schema checks I'm pretty sure
There was a problem hiding this comment.
It's pretty much the discussion on slack tech-support currently. Not a clue how to remove the flaky test without this though. The other suggestion on slack was to remove 2 lines of the plugins.yaml file, but it didn't work for me.
There was a problem hiding this comment.
I think the discussion only said to add the if statement, not delete everything else?
There was a problem hiding this comment.
actually if you merge in main now, we can probably revert this change as well (I fixed the tests another way)
more correct flaky test solution.




Fixes #10
Before
2026-02-07.17-32-51.mp4
After
2026-02-07.17-29-38.mp4