Commit 966a79a
fix(pat-structure): keep table rows in collection order
The table row rendering iterated the collection with an async callback
(`collection.each(async ...)`) that appended each row only after awaiting
`view.render()`. Row rendering is async (it awaits icon resolution), so
rows were appended in the arbitrary order their render promises resolved
rather than in collection order, corrupting the sort order of the folder
contents.
This stayed hidden until 5.6.0: DataTables was initialized with
`order: [0, "asc"]`, which re-sorted the rows by the hidden `_sort`
column (the server order index) on every draw and thus masked the race.
Commit 57cd7dd ("Fix ordering logic.") changed this to `order: []`,
removing the safety net and exposing the underlying bug.
Fix the root cause: build the row views in collection order, render them
all in parallel via `Promise.all`, then append them in order. This
guarantees the DOM order matches the collection order regardless of the
DataTables ordering settings. The now-obsolete
`table_row_rendering_finished` event dance and its `events` import are
removed.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 3434c84 commit 966a79a
1 file changed
Lines changed: 11 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| |||
125 | 124 | | |
126 | 125 | | |
127 | 126 | | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
| 127 | + | |
| 128 | + | |
132 | 129 | | |
133 | 130 | | |
134 | 131 | | |
| |||
139 | 136 | | |
140 | 137 | | |
141 | 138 | | |
142 | | - | |
| 139 | + | |
143 | 140 | | |
144 | 141 | | |
145 | 142 | | |
146 | 143 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | 144 | | |
156 | 145 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
174 | 154 | | |
175 | | - | |
176 | | - | |
177 | 155 | | |
178 | 156 | | |
179 | 157 | | |
| |||
0 commit comments