Conversation
The status code input was clamping values on every keystroke, making it impossible to type codes like "504" because typing "5" would immediately clamp to 100. Changed from type="number" to type="text" with numeric input mode, allowing users to clear the field and type any 3-digit value. Clamping to valid HTTP range (100-599) now only happens on blur.
eaa99cc to
4355cd3
Compare
…t race condition When a user types a complete 3-digit status code (like "700"), immediately clamp it to the valid HTTP range (100-599). This prevents a race condition where clicking "Create Monitor" before the blur event could submit an unclamped invalid value. The blur handler remains as a fallback for 1-2 digit values like "50".
Add normalizeAssertion function that recursively clamps status code values to the valid HTTP range (100-599) in onPreSubmit. This ensures invalid values can never be submitted, regardless of input length or blur timing. This complements the 3-digit immediate clamping in the input component by providing a safety net at the form submission level. Includes unit tests for the normalizeAssertion function covering: - Clamping values above range (700 -> 599) - Clamping values below range (50 -> 100) - Preserving valid values (404) - Recursive normalization of nested and/or/not operations - Passthrough of non-status-code operations
Remove normalizeAssertion function and tests since blur always fires before form submission, making the onPreSubmit normalization redundant. The input-level clamping (on blur and 3-digit input) is sufficient.
Update test selectors from 'spinbutton' (number input) to 'textbox' (text input) and change numeric value assertions to string values to match the input type change in opStatusCode.tsx.
Abdkhan14
reviewed
Jan 21, 2026
| type="text" | ||
| inputMode="numeric" | ||
| pattern="[0-9]*" | ||
| value={isNaN(value.value) ? '' : value.value} |
Contributor
There was a problem hiding this comment.
Would this fallback to a default for ''? If not it should to 200 right?
Contributor
There was a problem hiding this comment.
Otherwise looks good to me
Member
Author
There was a problem hiding this comment.
Yeah the fallback to default is actually happening onBlur as opposed to onChange, I wrote it this way to allow the user to completely clear the field (with the delete key), otherwise the onChange clamp would prevent that behavior.
I made a couple additional changes here:
- if value is '' (or NaN) on blur, fallback to 200 (previously was 100 via clamp)
- added comment explaining the fallback logic of the value prop.
Change the fallback value from 100 to 200 when the status code input is cleared and blurred. This is consistent with the default value used when adding a new status code assertion. Also adds a comment explaining why the value prop displays an empty string during editing (when value is NaN) and clarifies that the actual default is applied on blur.
Re-add normalizeAssertion function to handle edge case where user clears the status code input and submits via ENTER without blurring. This ensures NaN values are converted to 200 (the default) and out-of-range values are clamped before form submission. The normalization: - Defaults NaN to 200 (matches the default when adding new assertion) - Clamps values to valid HTTP range (100-599) - Recursively handles nested assertions in and/or/not groups
Abdkhan14
approved these changes
Jan 21, 2026
Move normalizeAssertion from uptimeAlertForm.tsx to field.tsx and apply it via the getData prop on FormField. This ensures assertion values are normalized before submission for both: - Alerts form (/issues/alerts/new/uptime/) - Detectors form (/monitors/new/) The normalization handles NaN values (from cleared inputs) by defaulting to 200, and clamps values to the valid HTTP status code range (100-599).
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
getData only works for save-on-blur scenarios. getValue is the correct prop to use for transforming field values at form submission time, as it is used by getTransformedData() which is called during saveForm().
The getValue prop was already supported by the form model for transforming field values at submission time, but was missing from the FormFieldProps interface, causing TypeScript errors when used directly on FormField components.
…m submission Tests verify that: - NaN values are normalized to 200 via getTransformedData() - Out-of-range values are clamped to valid HTTP range (100-599)
The detector form submit hooks were using raw getData() which bypasses field-level getValue transformations. Changed to use getTransformedData() so that assertion normalization (and any future getValue transformations) are applied at submission time. This aligns with how the Form component works when no custom onSubmit is provided - it calls saveForm() which uses getTransformedData().
Abdkhan14
approved these changes
Jan 21, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
type="number"totype="text"withinputMode="numeric"to allow intermediate values during typingProblem
The
onChangehandler was running clamping logic on every keystroke. When typing "5" to start "504", it would immediately clamp to 100, making the field unusable.Additionally, if a user cleared the input and submitted the form (e.g., via ENTER key) before the blur handler fired, NaN values could be sent to the API.
Solution
Input Handling
type="text"withinputMode="numeric"andpattern="[0-9]*"for mobile keyboard supportForm Submission Normalization
normalizeAssertion()function inUptimeAssertionsFieldto ensure valid values at submission timegetValueprop (notgetData) to transform field values - this is important becausegetDataonly works for save-on-blur scenarios, whilegetValueis used bygetTransformedData()during full form submission viasaveForm()getValuetoFormFieldPropstype definition - the prop was already supported by the form model but was missing from the TypeScript interfaceUptimeAssertionsFieldcomponent so it works for both:/issues/alerts/new/uptime/)/monitors/new/settings/?detectorType=uptime_domain_failure)Detector Form Fix
useCreateDetectorFormSubmit,useEditDetectorFormSubmit) to useformModel.getTransformedData()instead of rawdataparameterdataparameter isgetData()which bypasses field-levelgetValuetransformationsFormcomponent works when no customonSubmitis providedTest Plan
userEventinstead of deprecatedfireEventStatefulWrapperfor tests that need controlled component state updatesnormalizeAssertion()function covering NaN handling and recursive normalizationgetValuenormalization works viamodel.getTransformedData()on form submissionFixes NEW-698