artefactual / artefactual/atom
Problem: Sidebar tree can sometimes repeat the same sibling records, causing infinite scrolling
- Dominant language
- PHP
- Stars
- 297
- Forks
- 152
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 3
Description
### Current Behavior
**Steps to reproduce the behavior**
This behaviour isn't consistent, but can appear when expanding hierarchy branches containing more than 8 records. The sidebar tree shows initial 8 records with '{X} more...' link below. Clicking this link, or scrolling the tree downwards triggers a call to _{atom url}/{slug}/informationobject/treeView?show=nextSiblings&resourceId={id}_. This can return 7 records - the first 4 siblings, then a repeat of the first 3. This behaviour then repeats on subsequent requests to get 'nextSiblings'. This behaviour is only relevant in the sidebar tree. An affected collection displays records correctly in full-width tree, or when displayed as a 'list'.
Example returned set from a broken _nextSiblings_ request:
- Item K/PP149/2/2/10 - Papers, 1959-1966, relating to Saunders' MD thesis, 'The control of pain in terminal cancer'
- Item K/PP149/2/2/11 - Transcripts, 1960-1963, of recorded conversations between Saunders and patients at St Joseph's Hospice, London
- Item K/PP149/2/2/12 - Transcripts of interviews, 1960-1963, with patients with surnames A-C, St Joseph's Hospice, London
- Item K/PP149/2/2/13 - Transcripts of interviews, 1960-1963, with patients with surnames D-F, St Joseph's Hospice, London
- Item K/PP149/2/2/10 - Papers, 1959-1966, relating to Saunders' MD thesis, 'The control of pain in terminal cancer'
- Item K/PP149/2/2/11 - Transcripts, 1960-1963, of recorded conversations between Saunders and patients at St Joseph's Hospice, London
- Item K/PP149/2/2/12 - Transcripts of interviews, 1960-1963, with patients with surnames A-C, St Joseph's Hospice, London
### Expected Behavior
The request to _{atom url}/{slug}/informationobject/treeView?show=nextSiblings&resourceId={id}_ should return the next 'N' sibling records without repeating.
### Possible Solution
It looks like the helper method @ https://github.com/artefactual/atom/blob/f7f5a638e5cd7b040de4f3e0da8fa47ccb117553/lib/model/QubitInformationObject.php#L2309 doesn't refer to any offset or 'start' parameters. The caller @ https://github.com/artefactual/atom/blob/f7f5a638e5cd7b040de4f3e0da8fa47ccb117553/apps/qubit/modules/informationobject/actions/treeViewComponent.class.php#L20 seems to just pass the current resource into getTreeViewChildren(), which runs a fresh query that finds the very first child of that resource, then gets the 'next' siblings ... so each fetch starts from the same first child. No offset or 'current child' is passed in (?) - so pagination still anchors to the first record, and the 'next N' list repeats those earliest rows.
### Context and Notes
_No response_
### Version used
AtoM 2.9.1 and 2.9.2 (not tested in 2.10+)
### Operating System and version
Ubuntu 22.04
### Default installation culture
en
### PHP version
_No response_
### Contact details
_No response_
Contributor guide
Research direction
Start by tracing the nextSiblings request through apps/qubit/modules/informationobject/actions/treeViewComponent.class.php and lib/model/QubitInformationObject.php, focusing on how getTreeViewChildren() determines the current position. Reproduce the sidebar behavior with a hierarchy containing more than eight records, then verify that successive nextSiblings requests return the next records without duplicates or infinite scrolling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100