Skip to content

🐛 Fix exercise intensity dropdown selection state#59

Merged
ebigunso merged 1 commit intomainfrom
fix/intensity-dropdown-selection
Feb 24, 2026
Merged

🐛 Fix exercise intensity dropdown selection state#59
ebigunso merged 1 commit intomainfrom
fix/intensity-dropdown-selection

Conversation

@ebigunso
Copy link
Owner

@ebigunso ebigunso commented Feb 24, 2026

Summary

  • Fixes exercise intensity dropdown selection reverting in create/edit flows.
  • Removes fragile dependency on wrapper-level change handling inside SleepForm by using deterministic sync logic.
  • Adds explicit event forwarding (input, change, blur, focus) in Input wrapper for safer parent event handling.
  • Adds focused non-E2E regression tests for intensity state synchronization behavior.
  • Archives the investigation plan and records lessons learned.

Root cause

  • SleepForm reset logic could overwrite user-selected intensity before dirty state was reliably established via wrapper event behavior.

Validation

  • cd sleep-ui && npm run check ✅
  • npm run test:unit ✅ (54 tests)

Notes

  • Follows non-E2E-first validation strategy for this bug scope.

Copilot AI review requested due to automatic review settings February 24, 2026 15:40
@ebigunso ebigunso self-assigned this Feb 24, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where selecting light or hard exercise intensity in the dropdown would revert to the initial value. The fix introduces deterministic state synchronization logic and explicit event forwarding to ensure user selections are preserved while still supporting late initial value updates for untouched fields.

Changes:

  • Replaced fragile on:change event handling with a deterministic syncIntensityState utility function that tracks dirty state and previous initial values
  • Added explicit event forwarding (input, change, blur, focus) in the Input.svelte wrapper component
  • Added focused unit tests validating intensity state synchronization behavior across key scenarios

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
sleep-ui/tests/unit/intensity.spec.ts New test suite covering intensity state sync logic including dirty state tracking and late initial value updates
sleep-ui/src/lib/utils/intensity.ts New utility module providing deterministic intensity state synchronization logic
sleep-ui/src/lib/components/SleepForm.svelte Replaced reactive statement with syncIntensityState call and removed wrapper-level on:change handler
sleep-ui/src/lib/components/Input.svelte Added event dispatcher and explicit event forwarding for safer parent event handling
docs/coding-agent/plans/completed/exercise-intensity-dropdown-investigation-plan.md Archived investigation plan documenting the bug analysis and fix approach
docs/coding-agent/lessons.md Added two new lessons learned about research task approval and test layer selection

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

@ebigunso ebigunso changed the title Fix exercise intensity dropdown selection state 🐛 Fix exercise intensity dropdown selection state Feb 24, 2026
@ebigunso ebigunso merged commit bb5f3e4 into main Feb 24, 2026
5 of 6 checks passed
@ebigunso ebigunso deleted the fix/intensity-dropdown-selection branch February 24, 2026 15:42
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.

2 participants