Skip to content

Bug/Search: All Categories#31

Merged
yuriiShmal merged 16 commits into
mainfrom
fix-search
Feb 11, 2026
Merged

Bug/Search: All Categories#31
yuriiShmal merged 16 commits into
mainfrom
fix-search

Conversation

@yuriiShmal
Copy link
Copy Markdown

Fixes #10

  • Searching now defaults to all-search when you first open the advanced search window (before hand, search did not occur until the search button was pressed, which caused downstream all search bugs)
  • All Categories selection in the categories dropdown now properly searches through all the categories instead of searching through no categories before

Before

2026-02-07.17-32-51.mp4

After

2026-02-07.17-29-38.mp4

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
@railway-app
Copy link
Copy Markdown

railway-app Bot commented Feb 7, 2026

🚅 Deployed to the nodebb-spring-26-clean-cod-pr-31 environment in Clean Code Team (nodebb)

Service Status Web Updated (UTC)
nodebb-spring-26-clean-code ✅ Success (View Logs) Web Feb 11, 2026 at 12:18 am

@coveralls
Copy link
Copy Markdown

coveralls commented Feb 7, 2026

Pull Request Test Coverage Report for Build 21887552135

Warning: 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

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 8 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.004%) to 78.872%

Files with Coverage Reduction New Missed Lines %
src/topics/index.js 8 88.68%
Totals Coverage Status
Change from base Build 21784164764: 0.004%
Covered Lines: 25384
Relevant Lines: 30354

💛 - Coveralls

@cirex-web
Copy link
Copy Markdown

cirex-web commented Feb 8, 2026

nice!
oh yea add your github account to https://railway.com/invite/UaE8exWsnIo to get automatic PR previews

@cirex-web
Copy link
Copy Markdown

I'll review the code soon

@cirex-web cirex-web closed this Feb 8, 2026
@cirex-web cirex-web reopened this Feb 8, 2026
@railway-app railway-app Bot temporarily deployed to Clean Code Team (nodebb) / nodebb-spring-26-clean-cod-pr-31 February 8, 2026 00:56 Destroyed
Comment on lines +74 to +80
const hasRenderedResults = !!$('#results .search-results').length;
const term = (searchFilters.term || '').trim();

if (term && !hasRenderedResults && lastAutoQueryUrl !== currentUrl) {
lastAutoQueryUrl = currentUrl;
searchModule.query(searchFilters);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to do a double-fetch on any subsequent query (eg. try changing the search text)

Image

was the intention to run search once on load?

(prod version:)

Image

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was the intention to run search once on load?

Yep, it was.

Comment thread public/src/client/search.js Outdated
$('[component="category/filter/button"]').toggleClass(
'active-filter', isActive
).find('.filter-label').translateText(labelText);
$('[component="category/filter/button"]')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there seems to be a bug where if you close the category dropdown and then reopen it, the checkmark disappears

Image Image

Copy link
Copy Markdown
Author

@yuriiShmal yuriiShmal Feb 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread public/src/client/search.js Outdated
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;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does ajaxify.data.selectedCids = cids; do exactly?

Copy link
Copy Markdown
Author

@yuriiShmal yuriiShmal Feb 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 []

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kk

Copy link
Copy Markdown

@cirex-web cirex-web left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heyo - I left some comments

@railway-app railway-app Bot temporarily deployed to Clean Code Team (nodebb) / nodebb-spring-26-clean-cod-pr-31 February 8, 2026 04:34 Destroyed
@railway-app railway-app Bot temporarily deployed to Clean Code Team (nodebb) / nodebb-spring-26-clean-cod-pr-31 February 8, 2026 04:36 Destroyed
@railway-app railway-app Bot temporarily deployed to Clean Code Team (nodebb) / nodebb-spring-26-clean-cod-pr-31 February 8, 2026 05:23 Destroyed
@cirex-web
Copy link
Copy Markdown

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;
}

@yuriiShmal
Copy link
Copy Markdown
Author

yuriiShmal commented Feb 8, 2026

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.

@cirex-web
Copy link
Copy Markdown

and will not auto search if you open a search page for a second time after having left it

what does this mean exactly?

@yuriiShmal
Copy link
Copy Markdown
Author

and will not auto search if you open a search page for a second time after having left it

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).
Then you try searching for 111 again, and it does not auto search and says no matches found.

@cirex-web
Copy link
Copy Markdown

could you provide a video demo of what u mean? I can't seem to replicate that after changing the code to use firstInit

Screen.Recording.2026-02-08.at.11.52.01.AM.mov

@yuriiShmal
Copy link
Copy Markdown
Author

2026-02-08.11-54-35.mp4

@cirex-web
Copy link
Copy Markdown

cirex-web commented Feb 8, 2026

hmm I see...

seems like the issue is that using the search icon sends this query
https://nodebb-spring-26-clean-code-nodebb-spring-26-clean-cod-pr-33.up.railway.app/api/search?term=11111&in=titles&_=1770570471818 and populates the search page result section based on that

Pressing the actual search button (for the same search term) results in this query
https://nodebb-spring-26-clean-code-nodebb-spring-26-clean-cod-pr-33.up.railway.app/api/search?in=titles&term=11111&matchWords=all&by=&categories%5B%5D=all&searchChildren=false&hasTags=&replies=&repliesFilter=atleast&timeFilter=newer&timeRange=&sortBy=relevance&sortDirection=desc&showAs=posts&_=1770570471819

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)

@railway-app railway-app Bot temporarily deployed to Clean Code Team (nodebb) / nodebb-spring-26-clean-cod-pr-31 February 9, 2026 15:58 Destroyed
behavior: adds category all field to all searches
even those that may not need a category.
@railway-app railway-app Bot temporarily deployed to Clean Code Team (nodebb) / nodebb-spring-26-clean-cod-pr-31 February 10, 2026 19:57 Destroyed
be fixed later. Impact is low.
@railway-app railway-app Bot temporarily deployed to Clean Code Team (nodebb) / nodebb-spring-26-clean-cod-pr-31 February 10, 2026 19:57 Destroyed
@railway-app railway-app Bot temporarily deployed to Clean Code Team (nodebb) / nodebb-spring-26-clean-cod-pr-31 February 10, 2026 20:01 Destroyed
@railway-app railway-app Bot temporarily deployed to Clean Code Team (nodebb) / nodebb-spring-26-clean-cod-pr-31 February 10, 2026 20:35 Destroyed
@railway-app railway-app Bot temporarily deployed to Clean Code Team (nodebb) / nodebb-spring-26-clean-cod-pr-31 February 10, 2026 20:40 Destroyed
Comment thread test/api.js
schema = context[method].responses['200'].content['application/json'].schema;
compare(schema, result.body, method.toUpperCase(), path, 'root');
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we're allowed to remove everything here lmao. This removes like all api endpoint schema checks I'm pretty sure

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the discussion only said to add the if statement, not delete everything else?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@railway-app railway-app Bot temporarily deployed to Clean Code Team (nodebb) / nodebb-spring-26-clean-cod-pr-31 February 11, 2026 00:15 Destroyed
@yuriiShmal yuriiShmal merged commit 60dcf71 into main Feb 11, 2026
2 checks passed
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.

Fix Bug (public/src/search): Search All Categories Search searches No Categories

3 participants