Skip to content

fix: persist project/task changes when editing a time entry#209

Merged
EdiWeeks merged 4 commits into
mainfrom
fix/208-edit-entry-project-task-reverts
Jun 4, 2026
Merged

fix: persist project/task changes when editing a time entry#209
EdiWeeks merged 4 commits into
mainfrom
fix/208-edit-entry-project-task-reverts

Conversation

@EdiWeeks

@EdiWeeks EdiWeeks commented May 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The edit modal's reset effect listed selectedProject/selectedTask (and friends) in deps, so picking a new project mid-edit fired selectProject → re-ran the effect → snapped the form back to the original entry values.
  • handleSubmit only forwarded hours/notes on update — project and task changes were silently dropped even when the UI did show them.
  • A BC timesheet line is bound to a single project+task, so a project/task change is now treated as a replacement: delete the original entry and create a new line on the chosen date. Hours-only / notes-only / date-only edits still use the existing in-place path.

Fixes #208

Test plan

  • Edit an existing entry, change the project and/or task, save → new project/task is reflected on the timesheet and persisted in BC
  • Edit an existing entry, change only hours/notes, save → existing line is updated in place (no new line created)
  • Edit an existing entry, change only the date, save → entry moves to the new date on the same line
  • Create a new entry → unaffected

🤖 Generated with Claude Code

The edit modal's reset effect re-ran whenever selectedProject/selectedTask
changed in the store, which happened mid-edit and clobbered the user's new
selection. Submitting also only forwarded hours/notes, so even visual edits
to project/task were silently dropped. A BC line is bound to one project+task,
so a project/task change now replaces the entry (delete + add) instead of
attempting an in-place patch. Fixes #208.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 22, 2026 07:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an issue in the timesheet time-entry edit modal where changing project/task selections would revert and where project/task updates were not persisted to Business Central. The PR also aligns edit behavior with BC’s constraint that a timesheet line is bound to a single project+task by treating project/task changes as a replacement operation.

Changes:

  • Prevent the modal “reset form” effect from re-running on project/task selection changes (fixes selection snapping back).
  • Persist project/task edits by replacing the original entry (delete + create) when project/task changes; keep in-place update behavior for hours/notes/date-only edits.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/timesheet/TimeEntryModal.tsx Outdated
Comment thread src/components/timesheet/TimeEntryModal.tsx
EdiWeeks and others added 2 commits May 22, 2026 08:30
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Replace eslint-disable on the reset effect with a resetKey ref so the
  body still re-runs on background projects refreshes, just not on
  incidental dep churn from selectProject/selectTask.
- Create the replacement entry before deleting the original when project
  or task changes, so a BC failure mid-flight no longer risks losing the
  user's original hours and notes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 22, 2026 07:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread src/components/timesheet/TimeEntryModal.tsx
Comment thread src/components/timesheet/TimeEntryModal.tsx
- Surface a specific toast and close the modal when the post-add
  delete fails, so the user knows the original line still exists and
  needs to be removed manually rather than seeing a generic save error.
- Correct the reset-effect comment to match the actual guard behavior:
  the resetKey ref intentionally skips background dep changes (including
  projects refreshes) to protect in-progress edits, not to forward them.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@EdiWeeks EdiWeeks requested a review from BenGWeeks May 29, 2026 08:12
@EdiWeeks EdiWeeks merged commit 2569234 into main Jun 4, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Editing time entry: project and task selections revert to original values

3 participants