File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -260,7 +260,8 @@ export class BookSort extends Component {
260260 animation : 150 ,
261261 fallbackOnBody : true ,
262262 swapThreshold : 0.65 ,
263- onSort : ( ) => {
263+ onSort : ( event ) => {
264+ this . ensureNoNestedChapters ( )
264265 this . updateMapInput ( ) ;
265266 this . updateMoveActionStateForAll ( ) ;
266267 } ,
@@ -273,6 +274,20 @@ export class BookSort extends Component {
273274 }
274275 }
275276
277+ /**
278+ * Handle nested chapters by moving them to the parent book.
279+ * Needed since sorting with multi-sort only checks group rules based on the active item,
280+ * not all in group, therefore need to manually check after a sort.
281+ * Must be done before updating the map input.
282+ */
283+ ensureNoNestedChapters ( ) {
284+ const nestedChapters = this . container . querySelectorAll ( '[data-type="chapter"] [data-type="chapter"]' ) ;
285+ for ( const chapter of nestedChapters ) {
286+ const parentChapter = chapter . parentElement . closest ( '[data-type="chapter"]' ) ;
287+ parentChapter . insertAdjacentElement ( 'afterend' , chapter ) ;
288+ }
289+ }
290+
276291 /**
277292 * Update the input with our sort data.
278293 */
You can’t perform that action at this time.
0 commit comments