Skip to content

Commit ec43fa4

Browse files
committed
feat: add smooth scroll to transaction form when editing transactions
1 parent e564fd4 commit ec43fa4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/pages/Index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,14 @@ const Index = () => {
320320
const handleEditTransaction = (transaction: Transaction) => {
321321
setEditingTransaction(transaction);
322322
setShowTransactionForm(true);
323+
324+
// Scroll to the form if it's already visible, otherwise wait for it to render
325+
setTimeout(() => {
326+
const formElement = document.getElementById('transaction-form');
327+
if (formElement) {
328+
formElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
329+
}
330+
}, 100);
323331
};
324332

325333
const expenses = transactions.filter(transaction => transaction.type === 'expense');
@@ -439,7 +447,7 @@ const Index = () => {
439447
</Button>
440448
</div>
441449
</CardHeader>
442-
<CardContent className="pt-6 px-6">
450+
<CardContent className="pt-6 px-6" id="transaction-form">
443451
<TransactionForm
444452
onSubmit={addTransaction}
445453
onCancel={() => {

0 commit comments

Comments
 (0)