fix: reject unsubmittable participant shares in the percentage UI - #1381
Merged
SheyeJDev merged 2 commits intoSep 27, 2026
Merged
Conversation
…omponents/splits/ParticipantPercentageValidation.tsx
…omponents/splits/ParticipantPercentageValidation.test.ts
|
@blesswill88 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
LGTM |
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.
Overview
The percentage UI validated only the total. Because shares are basis-point
integers, a total of exactly 10000 said nothing about whether the individual
shares were submittable:
[10500, -500]sums to 10000, so the form showed a green "Shares total 100%."and let the user submit a split where one participant is owed a negative amount
and another is above 100%. The server then rejected it — the UI's job is to
catch that first. Fractional and non-numeric shares slipped through the same
way.
Related Issue
Closes #1321
Changes
ParticipantPercentageValidation.tsxnon-negative number of basis points not exceeding 10000. Violations are
reported as
invalidShareswith anindex,labeland machine-readableproblem(not_a_number,not_whole_basis_points,negative,above_total).added; otherwise two broken shares could mask each other, which is exactly
the bug above.
isValidnow requires both no invalid shares and a total of 10000. Themessage names the offending participant(s) and counts the remainder, so the
user is told which row to fix rather than only that the sum is wrong.
data-testid/data-validhooks androle="status"semantics.onValidityChangemoved out ofuseMemointouseEffect. Calling theparent's setter during the render phase is a side effect in render — React
warns about it and it could loop when the parent's state fed back in — and
it fired on every keystroke even when validity had not changed.
ParticipantPercentageValidation.test.ts— adds the per-share cases: alegal total built from illegal shares, fractional and non-numeric shares,
message wording, the zero-share exclusion, and a missing list. The four
original tests are unchanged apart from asserting
invalidShares.Verification Results
shouldBlockSubmit/isValidreject impossible shares even when the total is 100%