Repository navigation
[2.x] refactor(core): rewrite PostStreamScrubber in TS and improve e11y - #5448
DavideIadeluca wants to merge 3 commits into
Conversation
|
Note Automated review for @DavideIadeluca. Multiple AI models with Flarum-specific knowledge reviewed this pull request for me, and a further agent verified their findings; I haven't read it myself yet. I'll look at this pull request personally as soon as I can.
All three reviewers completed. The branch merges cleanly into |
|
I have let AI try to address the review feedback. Additionally I opted to restore the |
imorland
left a comment
There was a problem hiding this comment.
Requesting changes because conditional items added through the new extension hooks can permanently disable scrubber navigation. I reproduced this on a dev forum running 990736fe5, as a guest, with a 40-post discussion.
1. Conditional extension items leave the scrollbar without click and drag handlers
The new ItemLists have unkeyed children. When an extension adds or removes a button before the scrollbar, Mithril can replace the scrollbar DOM. Its event handlers are attached only in the parent component’s oncreate, which does not run again when those children are replaced.
To reproduce:
- Add a conditional button to
scrubberItems()at priority50, betweenfirstandscrollbar. Add a separate control to toggle its visibility. - Open a discussion with enough posts to scrub through.
- Drag the handle to confirm navigation works.
- Toggle the conditional button off and allow Mithril to redraw.
- Try dragging the replacement handle or clicking the track.
In my test, the initial drag moved from post 1 to post 25. Removing the conditional button replaced the scrollbar and cleared its handle sizing. Subsequent dragging and track clicks left the discussion at post 25.
Video: working navigation, then broken navigation after removing the extension item:
0cee359f-76d0-4c84-88cf-50d1fff33c22-d20509c3-1787-47e4-98d8-143d4191849b-mp4.mp4
This matters for ordinary conditional controls, such as a “first unread” button that disappears when there are no unread posts. The new hooks need to preserve the relevant DOM identities, or ensure replacement elements receive their handlers and sizing. Please add a test that toggles an extension item across redraws and then exercises navigation; the current tests cover only the initial render.
2. The oversized-handle test accepts endpoint jumps
The new clamp can make percentPerPost().index zero when the minimum handle height consumes the track. Dragging then divides by zero and jumps to an endpoint.
To reproduce using the configuration in the new test:
- Set
PostStreamScrubber.minHandleHeight = 150. - Set
.Scrubber-scrollbarto a height and maximum height of100px. - Open the 40-post discussion around post 6.
- Drag the handle down with a vertical displacement of 1px.
I observed the scrubber change from “6 of 40 posts” to “39 of 40 posts” during movement, then navigate to the final post on release.
Video: oversized handle and endpoint jump:
0cee359f-76d0-4c84-88cf-50d1fff33c22-18445759-a25f-47a9-a662-9ce3d5c58af2-mp4.mp4
The underlying short-track problem predates this PR: the old implementation also divided by zero at a 50px track, and moved backwards below that height. This is therefore incomplete edge-case handling rather than a wholly new regression. However, the newly supported minimum height exposes it, and the new index >= start assertion passes when dragging jumps straight to the end.
Please define the intended behavior when the handle fills the track and assert the actual resulting position in the test.
Progresses #3533
Changes proposed in this pull request:
Rewrite the
PostStreamScrubberin TS and improve extensibilityReviewers should focus on:
This change in theory should be 100% backwards compatible. Do we though want to mark some of the internals as such or as private to not tie up our hands too much in the future in regards to making changes to this component?
Screenshot
(No-Op)
Before:

After:

Necessity
Confirmed
yarn testinjs/).composer test).Required changes: