Go to file
Ted Johansson 002dd91a05
FIX: Fix an issue where deselecting a filter tag would cause no results (#126)
In some cases, when having multiple tag filters selected and results in the list, deselecting one of the filters would cause no results. This is clearly incorrect behavior, as fewer filters should lead to more (or at least the same number of) results.

This happens when you have a list of selected filters, e.g. `foo|bar|baz`, and you deselect the "middle" one. This will result in the following filter: `foo||baz`, which causes the back-end to try and filter on empty string as well, and in turn leads to no results.

The order of the filter list depends on the order they were selected, which caused this to seem a bit erratic.

In the code, there's a regular expression that tries to remove consecutive `|` characters, but this is anchored to the beginning of the string, so it doesn't work for this case.

Instead of relying on a regular expression, this change splits the string into an array, filters out the deselected tag, and joins it back together into the filter string. This avoids the issues that regular expressions have.

The PR also includes unit tests for the three code paths of the filter selection.
2023-04-03 13:56:41 +08:00
.github/workflows DEV: Update CI workflows (#121) 2023-01-10 18:17:35 +00:00
app DEV: Introduce syntax_tree for ruby formatting (#118) 2022-12-29 13:31:34 +01:00
assets FIX: Fix an issue where deselecting a filter tag would cause no results (#126) 2023-04-03 13:56:41 +08:00
config Update translations (#123) 2023-02-21 17:12:22 +01:00
db/migrate FEATURE: Rename from Knowledge Explorer to Docs (#27) 2021-01-18 10:38:09 -06:00
lib DEV: Introduce syntax_tree for ruby formatting (#118) 2022-12-29 13:31:34 +01:00
spec DEV: Introduce syntax_tree for ruby formatting (#118) 2022-12-29 13:31:34 +01:00
test/javascripts FIX: Fix an issue where deselecting a filter tag would cause no results (#126) 2023-04-03 13:56:41 +08:00
.discourse-compatibility FEATURE: improve blank page syndrome (#79) 2022-01-28 20:10:53 +04:00
.eslintrc DEV: apply coding standards (#9) 2020-09-04 13:22:46 +02:00
.gitignore DEV: Update CI workflows, fix linting issues (#32) 2021-04-27 20:49:34 +02:00
.prettierrc DEV: Update CI workflows, fix linting issues (#32) 2021-04-27 20:49:34 +02:00
.rubocop.yml DEV: Introduce syntax_tree for ruby formatting (#118) 2022-12-29 13:31:34 +01:00
.streerc DEV: Introduce syntax_tree for ruby formatting (#118) 2022-12-29 13:31:34 +01:00
.template-lintrc.js DEV: apply coding standards (#9) 2020-09-04 13:22:46 +02:00
Gemfile DEV: Introduce syntax_tree for ruby formatting (#118) 2022-12-29 13:31:34 +01:00
Gemfile.lock DEV: Introduce syntax_tree for ruby formatting (#118) 2022-12-29 13:31:34 +01:00
LICENSE DEV: Update CI workflows, fix linting issues (#32) 2021-04-27 20:49:34 +02:00
README.md Update README.md (#60) 2021-10-04 12:36:30 -04:00
package.json DEV: Bump eslint-config-discourse and correct violations 2022-01-26 14:46:52 +00:00
plugin.rb DEV: Introduce syntax_tree for ruby formatting (#118) 2022-12-29 13:31:34 +01:00
translator.yml DEV: Add Crowdin support (#42) 2021-04-15 22:03:56 +02:00
yarn.lock DEV: Update eslint-config-discourse, use prettier for hbs (#119) 2023-01-04 13:36:19 +01:00

README.md

Discourse Docs Plugin

Find and filter knowledge base topics.

For more information, please see: https://meta.discourse.org/t/discourse-docs-documentation-management-plugin/130172/