[Alerting v2] [Rule authoring] Fix rule name validation and error visibility in create/edit flow#260337
Conversation
Addresses rule name validation inconsistencies between the page and flyout forms. "Untitled rule" is now rejected as a placeholder name, empty names show a clear error, and the error callout scrolls into view when validation fails in the flyout. Also moves the error callout above the name field so it is immediately visible. Closes elastic/rna-program#236 Made-with: Cursor
ApprovabilityVerdict: Needs human review This PR adds form validation to prevent saving rules with empty or default placeholder names, and improves error visibility by scrolling validation errors into view. While the changes are straightforward bug fixes with good test coverage, the author does not own any of the modified files — all are owned by @elastic/rna-project-team, who should review these changes. You can customize Macroscope's approvability policy. Learn more. |
💔 Build Failed
Failed CI Steps
Test Failures
Metrics [docs]Public APIs missing comments
Async chunks
Page load bundle
History
|
ana-davydova
left a comment
There was a problem hiding this comment.
Tested and reviewed the code!
…heck * commit '6f040b29a5220ce12886a9731f656613e50aff06': (34 commits) [Entity Analytics] Add entity resolution UI to service flyout (elastic#260504) [Dashboard] Fix setState in embeddables (elastic#260082) [EDR Workflows] Unskip FTR tests that failed due to transient Fleet service unavailability (elastic#260519) [Observability:Streams] Fix query streams error handling test (elastic#260777) [Alerting v2] Dispatcher grouping modes, throttle strategies, and matcher autosuggestion (elastic#260249) [Dashboard] State extraction as a consistent override (elastic#259839) [Alerting v2] [Rule authoring] Fix rule name validation and error visibility in create/edit flow (elastic#260337) [Fix] re-introduce sln breadcrumbs to unified rules (elastic#260289) [Security Solution][Endpoint] Updated kibana docs to include `xpack.securitySolution.maxEndpointScriptFileSize` as configurable in cloud (elastic#260568) [Alerting v2] updated the alerting-v2-constants package with artifacts constants, fix to the runbook max characters (elastic#260342) [Automatic Import V2] Provide user tooltips (elastic#260725) [One Workflow] Deduplicate step types by base type in workflow list (elastic#260763) [Security Solution] Execution results UI: Enable the feature flag (elastic#260711) [Metrics][Discover] internal/search/esql_async returns 200 but METRICS_INFO responds with error (elastic#260746) Collapse redundant anyOf/oneOf array unions in OAS query params (elastic#260585) [Unified rules] Hide stack rules from global search (elastic#260088) [Agent Builder] Sidebar navigation updates (elastic#260728) [* As Code] Use PUT for upserts (elastic#260318) Update EUI to v114.0.0 (elastic#259497) [Entity Resolution] Add contextual-security-apps as co-owner of resolution paths (elastic#260659) ... # Conflicts: # src/platform/plugins/shared/dashboard/public/index.ts
…ibility in create/edit flow (elastic#260337) ## Summary [Discover - Elastic (5).webm](https://github.com/user-attachments/assets/b517a3fc-6a1b-47fa-9754-7ca8d61e352d) - **Reject "Untitled rule" as a valid name**: The placeholder text is now treated as invalid, ensuring users provide a meaningful rule name before saving. - **Scroll error callout into view**: When form validation fails (in both the page and flyout), the error callout now auto-scrolls into the viewport so the user sees immediate feedback. - **Move error callout above the name field**: The validation summary now renders above the rule name for better visibility. Closes elastic/rna-program#236 ### Changes **Rule form package** (`@kbn/alerting-v2-rule-form`): - `form/constants.ts` — Added shared `DEFAULT_RULE_NAME` constant - `form/fields/name_field.tsx` — Custom `validate` rule rejecting both empty names ("Name is required.") and the placeholder "Untitled rule" ("Please provide a unique rule name.") - `flyout/error_callout.tsx` — Added `useRef` + `useEffect` to `scrollIntoView()` on error, guarded with optional chaining for test environments - `form/rule_form.tsx` — Moved `ErrorCallOut` from `GuiRuleForm` to `RuleFormContent`, rendering above the `NameField` - `form/gui_rule_form.tsx` — Removed `ErrorCallOut` (moved to parent) - `flyout/rule_form_flyout.tsx` — Added `data-test-subj="ruleV2FlyoutSaveButton"` to the flyout save button - `index.ts` — Exported `DEFAULT_RULE_NAME` **Tests:** - Updated Jest tests for `name_field`, `error_callout`, and `use_form_defaults` - Added Scout UI tests for both the dedicated rule authoring page and the Discover flyout ## Test plan - [x] Navigate to the rule create page — verify "Untitled rule" is shown as placeholder - [x] Click Save without changing the name — verify "Name is required." error appears above the name - [x] Type "Untitled rule" as the name and save — verify "Please provide a unique rule name." error - [x] Type a real name and save — verify no name validation errors - [x] Open the rule form flyout from Discover (ES|QL mode → Rules menu → Create v2 ES|QL rule) — verify same validation behavior - [x] In the flyout, scroll down and click Save with invalid name — verify error callout scrolls into view
Summary
Discover.-.Elastic.5.webm
Closes elastic/rna-program#236
Changes
Rule form package (
@kbn/alerting-v2-rule-form):form/constants.ts— Added sharedDEFAULT_RULE_NAMEconstantform/fields/name_field.tsx— Customvalidaterule rejecting both empty names ("Name is required.") and the placeholder "Untitled rule" ("Please provide a unique rule name.")flyout/error_callout.tsx— AddeduseRef+useEffecttoscrollIntoView()on error, guarded with optional chaining for test environmentsform/rule_form.tsx— MovedErrorCallOutfromGuiRuleFormtoRuleFormContent, rendering above theNameFieldform/gui_rule_form.tsx— RemovedErrorCallOut(moved to parent)flyout/rule_form_flyout.tsx— Addeddata-test-subj="ruleV2FlyoutSaveButton"to the flyout save buttonindex.ts— ExportedDEFAULT_RULE_NAMETests:
name_field,error_callout, anduse_form_defaultsTest plan