fix: Expand a collapsed work item thread when its comment is linked
What does this MR do and why?
Following a same-page link to a comment in a resolved (collapsed) thread left the thread collapsed, so the comment stayed hidden. The target-note hash was read once from a non-reactive computed, and the discussion component only used the expand-on-load prop for its initial state.
This tracks the URL hash in reactive data updated on hashchange, and watches
the expand-on-load prop so a thread expands when it becomes the hash target.
Changelog: fixed Closes #632443 (closed)
Before / After
Before: Clicking a link to a comment inside a resolved, collapsed thread scrolled to the thread but left it collapsed, so the linked comment stayed hidden — the hash was read once and the thread only honored the expand prop on its initial render.
After: The URL hash is tracked reactively (updated on hashchange), and the
discussion expands when it becomes the hash target, so following a link to a
comment in a collapsed thread reveals that comment.
How to set up and validate locally
- Run the updated specs:
yarn jest spec/frontend/work_items/components/work_item_notes_spec.js spec/frontend/work_items/components/notes/work_item_discussion_spec.js - Or in the UI: on a work item with a resolved (collapsed) thread, open a link to a comment inside it (copy the comment's link and visit it) — the thread expands and the comment is shown.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #632443 (closed)