Skip to content

fix(popup): commit volume percentage on click-outside instead of discarding - #407

Open
YuriNachos wants to merge 1 commit into
ronitsingh10:mainfrom
YuriNachos:YuriNachos/w6-FineTune
Open

fix(popup): commit volume percentage on click-outside instead of discarding#407
YuriNachos wants to merge 1 commit into
ronitsingh10:mainfrom
YuriNachos:YuriNachos/w6-FineTune

Conversation

@YuriNachos

@YuriNachos YuriNachos commented Aug 8, 2026

Copy link
Copy Markdown

Closes #358.

Summary

The volume percentage popover (EditablePercentage) discarded the typed value when the user clicked outside or switched apps — only pressing Return committed. A half-typed but valid number was lost on any dismissal other than Return, which reads as broken. The typed value is now committed on those dismissals instead.

Changes

  • Route the click-outside / app-deactivation dismissal through commit() instead of cancel() (FineTune/Views/Components/EditablePercentage.swift).
  • The commit validation already discards garbage and out-of-range input (returns nil → applies nothing, identical to the old cancel() for invalid input), so click-outside with "abc" or "500" safely applies nothing; a valid number is kept.
  • Dismissal paths after this change:
    • Return = commit() (unchanged).
    • Esc = cancel() / discard (unchanged — the one explicit "abandon" path).
    • Click-outside / global click / app-deactivation = commit() (was cancel()).
  • The commit validation is extracted into a pure @testable static helper committedValue(from:in:), 1:1 with the previous inline validation (same % strip, trim, Int parse, range check), so it is unit-testable headlessly. The dismissal closure captures the struct by value, so no retain cycle is introduced.
  • New FineTuneTests/EditablePercentageCommitValueTests.swift covering the helper.

Testing

  • xcodebuild test -scheme FineTune -skip-testing:FineTuneUITests CODE_SIGN_IDENTITY=-TEST SUCCEEDED.
  • EditablePercentageCommitValueTests (6 cases, mutation-verifiable): valid int → applied; trailing % → stripped; whitespace → trimmed; out-of-range → nil (discard, not clamp); garbage → nil; empty → nil. Removing any step of the validation flips the relevant case red.
  • Manual matrix (left for owner): type a value, click outside → applied; type garbage, click outside → discarded; Esc → discarded.

…arding (ronitsingh10#358)

Typing a volume percentage and then clicking away (or Cmd-Tabbing to another
app) silently discarded the value, because the dismissal path called cancel()
rather than commit(). Route click-outside and app-deactivation through commit(),
which validates Int + range and silently ignores garbage, so only valid edits
are kept. Escape still discards via onExitCommand { cancel() }.

Validation is extracted into a unit-tested pure helper committedValue(from:in:)
so the Return-key and click-outside paths apply the same rule.

Co-Authored-By: Claude <noreply@anthropic.com>
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.

Volume percentage doesn't save

1 participant