{"record":{"id":"1a35e1ee4f5cf978","repo":"oxc-project/oxc","slug":"attr-name-must-be-accompanied-by-onblur-for","errorCode":null,"errorMessage":"`{attr_name}` must be accompanied by `onBlur` for accessibility.","messagePattern":"`(.+?)` must be accompanied by `onBlur` for accessibility\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/jsx_a11y/mouse_events_have_key_events.rs","lineNumber":26,"sourceCode":"\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 {\n    /// List of hover-in mouse event handlers that require corresponding keyboard event handlers.\n    hover_in_handlers: Vec<CompactStr>,\n    /// List of hover-out mouse event handlers that require corresponding keyboard event handlers.\n    hover_out_handlers: Vec<CompactStr>,\n}\n\nimpl Default for MouseEventsHaveKeyEventsConfig {\n    fn default() -> Self {","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/jsx_a11y/mouse_events_have_key_events.rs#L8-L44","documentation":"This is the `jsx_a11y/mouse-events-have-key-events` rule in oxlint (port of eslint-plugin-jsx-a11y). The library throws it when a JSX element has a hover-out mouse handler (default `onMouseOut`, configurable via `hoverOutHandlers`) but no `onBlur` handler. Hover interactions are invisible to keyboard-only and screen-reader users, so every mouse handler must have a focus-equivalent handler.","triggerScenarios":"A JSX opening element (HTML tag or configured custom element) carries `onMouseOut` (or any name listed in the rule's `hoverOutHandlers` config) while `onBlur` is absent. The `miss_on_blur` diagnostic constructor at crates/oxc_linter/src/rules/jsx_a11y/mouse_events_have_key_events.rs:25 is the code path that fires.","commonSituations":"Hover-triggered dropdown menus, tooltips, or highlighting effects written for mouse users only; custom components that spread props and accidentally drop `onBlur`; teams enabling the jsx-a11y recommended preset for the first time; migrating from ESLint to oxlint and seeing pre-existing violations surface.","solutions":["Add an `onBlur` handler to the same element that mirrors the `onMouseOut` behavior (and `onFocus` for `onMouseOver`).","If the hover-out logic is purely decorative, guard it with `event.relatedTarget` checks or remove it.","Extend the config `hoverOutHandlers`/`hoverInHandlers` lists if your codebase uses custom handler names.","As a last resort, disable the rule for that line with an oxlint disable comment."],"exampleFix":"// before\n<div onMouseOut={handleClose} />\n\n// after\n<div onMouseOut={handleClose} onBlur={handleClose} onFocus={handleOpen} />","handlingStrategy":"validation","validationCode":"npx oxlint --jsx-a11y/mouse-events-have-key-events src/","typeGuard":"// Type-level reminder: pair hover handlers with focus handlers\ntype HoverA11yProps<T> = T & { onMouseOut?: ...; onBlur?: ... };\n// Runtime check for element props before render:\nconst hasPairedHandlers = (p: Record<string, unknown>, mouse: string, key: string) =>\n  !(mouse in p) || (key in p);","tryCatchPattern":null,"preventionTips":["Whenever you add onMouseOver/onMouseOut, add onFocus/onBlur in the same commit.","Keep jsx-a11y recommended preset enabled in CI so violations never land.","For custom handler names, configure hoverInHandlers/hoverOutHandlers once in .oxlintrc.json."],"tags":["jsx-a11y","react","accessibility","keyboard-navigation","lint"],"backgroundTag":"missing-keyboard-event-handler","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}