Frontmatter
| id | 8138 |
| title | Support saveScrollPosition in DomApiRenderer |
| state | Closed |
| labels | enhancementaicore |
| assignees | tobiu |
| createdAt | Dec 17, 2025, 3:19 PM |
| updatedAt | Dec 19, 2025, 10:56 AM |
| githubUrl | https://github.com/neomjs/neo/issues/8138 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Dec 19, 2025, 10:56 AM |
Support saveScrollPosition in DomApiRenderer
tobiu assigned to @tobiu on Dec 17, 2025, 3:20 PM

tobiu
Dec 17, 2025, 3:39 PM
Input from Gemini 2.5:
✦ I have implemented the requested changes in
src/main/render/DomApiRenderer.mjs.Key Implementation Detail: I introduced a Post-Mount Queue pattern. Standard browser behavior prevents setting
scrollToporscrollLefton detached DOM nodes (nodes not yet inserted into the document) because they lack a layout box and overflow context.To solve this, the
createDomTreemethod now:
- Collects any nodes with
scrollToporscrollLeftproperties into apostMountUpdatesqueue during the recursive build phase.- Inserts the fully built tree into the live DOM.
- Immediately iterates through the queue to apply the scroll values now that the nodes have a valid rendering context.
This ensures that scroll positions are correctly restored when components are re-mounted or moved.
tobiu cross-referenced by #8139 on Dec 17, 2025, 3:55 PM
tobiu closed this issue on Dec 19, 2025, 10:56 AM
Context
Ticket #8137 introduced
scrollTopandscrollLeftas top-level properties onNeo.vdom.VNodeto enable preserving scroll state. These properties are currently applied inNeo.main.DeltaUpdatesfor theupdateNodeaction.Problem
The
insertNodeaction, which utilizesNeo.main.render.DomApiRendererwhenNeo.config.useDomApiRendereris true, does not currently respect these properties. As a result, when a component is re-mounted (e.g. moved in the DOM or restored from a cached state), its previous scroll position is lost.Goal
Update
Neo.main.render.DomApiRendererto check for and applyscrollTopandscrollLeftproperties from thevnodeto the created DOM element.Implementation Details
src/main/render/DomApiRenderer.mjs:createDomTree, after creating the DOM element, check ifvnode.scrollToporvnode.scrollLeftare present.domNode.