{"record":{"id":"7b62fab4ed83eca7","repo":"oxc-project/oxc","slug":"attr-name-must-be-accompanied-by-onfocus-for","errorCode":null,"errorMessage":"`{attr_name}` must be accompanied by `onFocus` for accessibility.","messagePattern":"`(.+?)` must be accompanied by `onFocus` for accessibility\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/jsx_a11y/mouse_events_have_key_events.rs","lineNumber":18,"sourceCode":"use oxc_ast::{AstKind, ast::JSXAttributeValue};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\nuse oxc_str::CompactStr;\nuse schemars::JsonSchema;\nuse serde::Deserialize;\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    globals::HTML_TAG,\n    rule::{DefaultRuleConfig, Rule},\n    utils::{get_element_type, get_prop_value, has_jsx_prop},\n};\n\nfn miss_on_focus(span: Span, attr_name: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"`{attr_name}` must be accompanied by `onFocus` for accessibility.\"\n    ))\n    .with_help(\"Try to add `onFocus`.\")\n    .with_label(span)\n}\n\nfn miss_on_blur(span: Span, attr_name: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"`{attr_name}` must be accompanied by `onBlur` for accessibility.\"))\n        .with_help(\"Try to add `onBlur`.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct MouseEventsHaveKeyEvents(Box<MouseEventsHaveKeyEventsConfig>);\n\n#[derive(Debug, Clone, JsonSchema, Deserialize)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct MouseEventsHaveKeyEventsConfig {","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/jsx_a11y/mouse_events_have_key_events.rs#L1-L36","documentation":"Raised by jsx-a11y/mouse-events-have-key-events when an element has a mouse event handler (e.g. onMouseOver, onMouseOut) but no corresponding focus handler (onFocus/onBlur). Mouse-only interactions are inaccessible to keyboard users.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/jsx_a11y/mouse_events_have_key_events.rs:18 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add onFocus alongside onMouseOver and onBlur alongside onMouseOut.","Expose the same behavior via focus events so keyboard users get equivalent functionality."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}