Skip to content

Restore UI state after calculation errors #5

@jordanhom

Description

@jordanhom

Summary

Validation failures or exceptions in handleCalculation leave the “Calculate & Visualize” button disabled with “Calculating…” text because the loading state is not restored, freezing the UI.

Steps to Reproduce

  1. Load the app.
  2. Leave Sex unset, enter a valid birth date, and submit.
  3. Observe that the button remains disabled and the UI no longer responds without a refresh.

Expected Behavior

After any failure, the button text/state should revert and the results area should display an error message so the user can correct inputs and retry.

Actual Behavior

The button stays disabled with “Calculating…”, the results area is cleared, and the user is stuck until reloading the page.

Relevant Logs or Screenshots

N/A

Environment Details

  • OS: macOS 14.6 (Apple Silicon)
  • Browser: Chrome 118

Impact / Severity

High — major functionality degraded

Regression?

  • This is a regression from a previous release

Affected Modules or Files

  • js/ui.js

Proposed Fix / Notes

Move the loading-state reset (textContent, disabled) and results messaging into a finally block or helper so both validation and runtime errors restore state. Add regression coverage for validation failures.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions