fix(wiki): stop the page list rebuilding on every autosave - #13
Merged
Conversation
The nav flash persisted after the sidebar-rail fix because this is a second, separate offender in a different element. The rail fix (workspace.js) was real; it just was not the thing flashing here. wiki.js flushSave updates one row's data and then calls renderPageList(), which opens with tree.innerHTML = "" and rebuilds every row. Off a 500ms autosave debounce that is a full teardown of the wiki page list every time typing pauses. The existing comment says "update the row in the list without re-fetching the whole index" — it avoids the fetch but still does the full DOM rebuild. A row renders exactly two things, the title and relTime(updated_at), and both belong to the row being saved. So patch that row in place: rows now carry data-page-id, and the save path updates the title and meta text directly. Falls back to renderPageList() when the row is not found (list not built yet, or a newly added page), so structural changes still repaint. Note this is deliberately NOT the diff-and-skip approach used for the rail: updated_at genuinely changes on every save, so the meta text really does need updating. Skipping would be wrong; rebuilding everything was just overkill. Used a dataset scan rather than a CSS.escape selector — it would have been the only CSS.escape in the codebase, and page ids are UUIDs, so the escaping bought nothing and added a first-and-only browser dependency. esprima parses wiki.js. Whether the flash is gone is a repaint, which only the operator can confirm on desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The nav flash persisted after the sidebar-rail fix because this is a second,
separate offender in a different element. The rail fix (workspace.js) was real;
it just was not the thing flashing here.
wiki.js flushSave updates one row's data and then calls renderPageList(), which
opens with tree.innerHTML = "" and rebuilds every row. Off a 500ms autosave
debounce that is a full teardown of the wiki page list every time typing pauses.
The existing comment says "update the row in the list without re-fetching the
whole index" — it avoids the fetch but still does the full DOM rebuild.
A row renders exactly two things, the title and relTime(updated_at), and both
belong to the row being saved. So patch that row in place: rows now carry
data-page-id, and the save path updates the title and meta text directly. Falls
back to renderPageList() when the row is not found (list not built yet, or a
newly added page), so structural changes still repaint.
Note this is deliberately NOT the diff-and-skip approach used for the rail:
updated_at genuinely changes on every save, so the meta text really does need
updating. Skipping would be wrong; rebuilding everything was just overkill.
Used a dataset scan rather than a CSS.escape selector — it would have been the
only CSS.escape in the codebase, and page ids are UUIDs, so the escaping bought
nothing and added a first-and-only browser dependency.
esprima parses wiki.js. Whether the flash is gone is a repaint, which only the
operator can confirm on desktop.
Opened automatically after the
tierscheck passed ond1c1aa29.The check is attached to this branch head, so this is mergeable now.