Skip to content

Truncate long property value lists on concept page#1825

Merged
osma merged 4 commits intomainfrom
issue1795-truncate-property-value-lists
Nov 6, 2025
Merged

Truncate long property value lists on concept page#1825
osma merged 4 commits intomainfrom
issue1795-truncate-property-value-lists

Conversation

@osma
Copy link
Member

@osma osma commented Nov 6, 2025

Reasons for creating this PR

Overwhelmingly long lists of property values on the concept page should be truncated, see #1795. This functionality exists in Skosmos 2, and this PR implements the same feature for Skosmos 3.

I looked at the jQuery-based implementation of this functionality in Skosmos 2 and adapted the same logic for Skosmos 3, but using vanilla JS instead. There is also a Cypress test that verifies that it works both in the initial page load and partial page load cases.

Example of the result (on the page http://localhost/Skosmos/ykl/fi/page/38.55 ):

kuva

Link to relevant issue(s), if any

Description of the changes in this PR

  • add vanilla JS code that truncates long lists of property values (by adding CSS classes to the elements), triggered on initial page load & partial page load
  • add CSS rules that hide/reveal property values as appropriate
  • add Cypress tests to verify the above

Known problems or uncertainties in this PR

  • The truncation limit is hardcoded at 15, as in Skosmos 2. It would take more work to make it configurable.
  • This PR only truncates regular property values, e.g. skos:narrower. It does not truncate the "terms in other languages" section, unlike Skosmos 2, where also these were truncated. In Skosmos 3, the DOM structure of the "in other languages" section is very different than regular properties, so the same code doesn't work for both.

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)

@osma osma requested a review from joelit November 6, 2025 08:57
@osma osma self-assigned this Nov 6, 2025
@osma osma moved this to Needs review in Skosmos 3.x Backlog Nov 6, 2025
@osma osma added this to the 3.0-beta.2 milestone Nov 6, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 6, 2025

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

Copy link
Contributor

@UnniKohonen UnniKohonen left a comment

Choose a reason for hiding this comment

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

LGTM!

@osma osma merged commit bdf2424 into main Nov 6, 2025
13 of 14 checks passed
@github-project-automation github-project-automation bot moved this from Needs review to Issue/PR closed in Skosmos 3.x Backlog Nov 6, 2025
@osma osma deleted the issue1795-truncate-property-value-lists branch November 6, 2025 11:31
@osma osma moved this from Issue/PR closed to Done (verified in test.dev.finto.fi, set Milestone 3.0 for both issue & PR, update docs) in Skosmos 3.x Backlog Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

truncate property value lists that are longer than set number of items with "show all X values" button

2 participants