fix(popup): commit volume percentage on click-outside instead of discarding - #407
Open
YuriNachos wants to merge 1 commit into
Open
fix(popup): commit volume percentage on click-outside instead of discarding#407YuriNachos wants to merge 1 commit into
YuriNachos wants to merge 1 commit into
Conversation
…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>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
commit()instead ofcancel()(FineTune/Views/Components/EditablePercentage.swift).nil→ applies nothing, identical to the oldcancel()for invalid input), so click-outside with"abc"or"500"safely applies nothing; a valid number is kept.commit()(unchanged).cancel()/ discard (unchanged — the one explicit "abandon" path).commit()(wascancel()).@testable statichelpercommittedValue(from:in:), 1:1 with the previous inline validation (same%strip, trim,Intparse, range check), so it is unit-testable headlessly. The dismissal closure captures the struct by value, so no retain cycle is introduced.FineTuneTests/EditablePercentageCommitValueTests.swiftcovering 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.