|
1118 | 1118 | return true; |
1119 | 1119 | } |
1120 | 1120 |
|
| 1121 | + async function rerenderRowsAfterSessionShapeChange(dateValue, sessionIndex = 0) { |
| 1122 | + await renderRows(renderedRows); |
| 1123 | + const dateKey = String(dateValue || "").trim(); |
| 1124 | + if (!isIsoDateString(dateKey)) return; |
| 1125 | + const targetIndex = Math.max(0, Number.parseInt(String(sessionIndex || 0), 10) || 0); |
| 1126 | + const selector = `.plan-session-distance[data-date="${dateKey}"][data-session-index="${targetIndex}"]`; |
| 1127 | + const target = bodyEl.querySelector(selector) || bodyEl.querySelector(distanceSelectorForDate(dateKey)); |
| 1128 | + if (!(target instanceof HTMLInputElement)) return; |
| 1129 | + target.focus(); |
| 1130 | + if (typeof target.select === "function") { |
| 1131 | + target.select(); |
| 1132 | + } |
| 1133 | + } |
| 1134 | + |
1121 | 1135 | function buildSessionTypeSelect(row, index, rows, session, sessionIndex) { |
1122 | 1136 | const select = document.createElement("select"); |
1123 | 1137 | select.className = "plan-run-type plan-session-type"; |
|
1254 | 1268 | const current = collectSessionPayloadForDate(row.date); |
1255 | 1269 | current.push({ ordinal: current.length + 1, planned_miles: 1.0, run_type: "", planned_workout: "" }); |
1256 | 1270 | saveSessionPayload(row, index, rows, row.date, current, { preserveFocus: true }); |
| 1271 | + void rerenderRowsAfterSessionShapeChange(row.date, Math.max(0, current.length - 1)); |
1257 | 1272 | }); |
1258 | 1273 | inlineActions.appendChild(addBtn); |
1259 | 1274 |
|
|
1267 | 1282 | const current = collectSessionPayloadForDate(row.date); |
1268 | 1283 | if (current.length > 0) current.pop(); |
1269 | 1284 | saveSessionPayload(row, index, rows, row.date, current, { preserveFocus: true }); |
| 1285 | + void rerenderRowsAfterSessionShapeChange(row.date, Math.max(0, current.length - 1)); |
1270 | 1286 | }); |
1271 | 1287 | inlineActions.appendChild(removeBtn); |
1272 | 1288 |
|
|
0 commit comments