Skip to content

Search bar fixes#1854

Merged
joelit merged 6 commits intomainfrom
search-bar-fixes
Dec 5, 2025
Merged

Search bar fixes#1854
joelit merged 6 commits intomainfrom
search-bar-fixes

Conversation

@joelit
Copy link
Contributor

@joelit joelit commented Dec 4, 2025

Reasons for creating this PR

Some unimplemented features were spotted in the global search bar. This addessess some of those.

Link to relevant issue(s), if any

Description of the changes in this PR

  • Do not pass content language (as null) to the search if it's not selected. Instead, use the UI language.
  • Fix global search autocomplete result links

Known problems or uncertainties in this PR

Checklist

  • phpUnit tests pass locally with my changes
  • I have added tests that show that the new code works, or tests are not relevant for this PR (e.g. only HTML/CSS changes)
  • The PR doesn't reduce accessibility of the front-end code (e.g. tab focus, scaling to different resolutions, use of .sr-only class, color contrast)
  • The PR doesn't introduce unintended code changes (e.g. empty lines or useless reindentation)

@joelit joelit self-assigned this Dec 4, 2025
@joelit joelit added this to the 3.0 milestone Dec 4, 2025
@joelit joelit moved this to Needs review in Skosmos 3.x Backlog Dec 4, 2025
@joelit joelit changed the title Use UI language as fallback language for search Search bar fixes Dec 4, 2025
const urlParams = this.formatSearchUrlParams()
if (this.selectedLanguage !== window.SKOSMOS.lang) { // add content language parameter
urlParams.append('clang', this.selectedLanguage)
result.pageUrl = window.SKOSMOS.baseHref + result.vocab + '/' + window.SKOSMOS.lang + '/page/?'
Copy link
Member

Choose a reason for hiding this comment

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

I think this should rather be done using the getConceptUrl method defined in get-concept-url.js. This is used by the sidebar components to generate concept page links. It's better to have this logic in just one place, and the function will also use a short form URL (/page/p12345) when possible instead of always using the ?uri= form.

The same applies to the vocab-search component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call - I made an issue (#1856 ) of the use of getConceptUrl in forming links for the concepts. I found out it leaves out the /Skosmos/ installation folder when forming concept links and it doesn't handle the content language too well, i.e. http://localhost/fi/page/?uri=http%3A%2F%2Fwww.yso.fi%2Fonto%2Fyso%2Fp19378&clang= so it needs to be polished a bit, and tested accross all the different use cases, adding tests etc.

Then it should be used here too.

Copy link
Member

@osma osma left a comment

Choose a reason for hiding this comment

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

LGTM. Seems to be an improvement overall.

I think updateSearchLang can now be deleted, see comment. Other than that, good for merging.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 5, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
57.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@joelit joelit merged commit e87281a into main Dec 5, 2025
21 of 23 checks passed
@github-project-automation github-project-automation bot moved this from Needs review to Issue/PR closed in Skosmos 3.x Backlog Dec 5, 2025
@joelit joelit deleted the search-bar-fixes branch December 5, 2025 10:14
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.

2 participants