Skip to content

Commit 60d6b64

Browse files
committed
fix(template-interactive-supports-focus): apply tabindex carve-outs to contenteditable (Copilot review)
Mirror the disabled/hidden-input guard already on the tabindex branch: the UA ignores contenteditable on disabled form controls and on <input type='hidden'> just as it ignores tabindex, so contenteditable must not count as satisfying the focus requirement in those cases.
1 parent c4b6ff7 commit 60d6b64

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

lib/rules/template-interactive-supports-focus.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,20 @@ module.exports = {
219219
}
220220
}
221221

222-
// contenteditable also makes an element focusable.
222+
// contenteditable also makes an element focusable, with the same
223+
// HTML-spec carve-outs as tabindex: the UA ignores it on disabled
224+
// form controls (HTML §4.10.18.5) and on <input type="hidden">
225+
// (no rendered element to edit), so the a11y conflict still stands.
223226
if (isContentEditable(node)) {
224-
return;
227+
const disabled = DISABLABLE_FORM_CONTROLS.has(tag) && findAttr(node, 'disabled');
228+
let hiddenInput = false;
229+
if (tag === 'input') {
230+
const type = getTextAttrValue(findAttr(node, 'type'));
231+
hiddenInput = typeof type === 'string' && type.trim().toLowerCase() === 'hidden';
232+
}
233+
if (!disabled && !hiddenInput) {
234+
return;
235+
}
225236
}
226237

227238
context.report({

0 commit comments

Comments
 (0)