Fix issues with moving cards jank.

This commit is contained in:
Chris McCormick 2025-12-30 20:49:56 +08:00
parent 409351aa70
commit 0ed1994a82
2 changed files with 12 additions and 12 deletions

View file

@ -2,16 +2,17 @@
## TODO
- [ ] Ability to create, move, remove columns.
- [ ] Ability to create a project on the projects select page, including if TODO.md is empty.
- [ ] Plus button in the columns to add a new item, with text input.
- [ ] Ability to create, move, remove columns.
- [ ] Minimize the number of times the user is asked for access. If possible ask for all the access required at one time.
- [ ] Plus button in the columns to add a new item, with text input.
## In progress
## Done
- [x] Moving cards around janks the file.
- [x] When dragging between columns we should show the insertion point and insert the card at that point.
- [x] Dropdown for setting the card as checked/unchecked.
- [x] Make it look more the makesprite/concrete.css theme.

View file

@ -467,9 +467,11 @@
const section = state.sections[state.currentSectionIndex];
const targetColumn = section.columns[targetColumnIndex];
const targetColumnIsEmpty = targetColumn.cards.length === 0;
const isInsertingAtBottom = insertPosition === targetColumn.cards.length;
console.log('Before move, source line', fromLine, '=', lines[fromLine]);
console.log('Target column is empty:', targetColumnIsEmpty);
console.log('Inserting at bottom:', isInsertingAtBottom);
const [movedLine] = lines.splice(fromLine, 1);
@ -499,11 +501,6 @@
}
lines.splice(actualInsertLine, 0, movedLine);
const afterLine = actualInsertLine + 1;
if (afterLine >= lines.length || lines[afterLine].trim() !== '') {
lines.splice(afterLine, 0, '');
}
} else {
console.log('Inserting at position', insertPosition);
const cardBefore = targetColumn.cards[insertPosition - 1];
@ -524,11 +521,13 @@
lines.splice(actualInsertLine, 0, movedLine);
}
const movedLineIndex = lines[actualInsertLine - 1] === movedLine ? actualInsertLine - 1 : actualInsertLine;
const afterLine = movedLineIndex + 1;
if (afterLine >= lines.length || lines[afterLine].trim() !== '') {
console.log('Ensuring blank line after moved item at line', afterLine);
lines.splice(afterLine, 0, '');
if (isInsertingAtBottom) {
const movedLineIndex = lines[actualInsertLine - 1] === movedLine ? actualInsertLine - 1 : actualInsertLine;
const afterLine = movedLineIndex + 1;
if (afterLine >= lines.length || lines[afterLine].trim() !== '') {
console.log('Inserting at bottom - ensuring blank line after moved item at line', afterLine);
lines.splice(afterLine, 0, '');
}
}
}
}