Skip to content

[Bug] Hidden textarea is keyboard-focusable due to "tab-index" typo (should be "tabindex") #80

@tyreer

Description

@tyreer

Bug Description

The hidden textarea created for auto-size height calculation is keyboard-focusable due to using the invalid HTML attribute tab-index (with hyphen) instead of the valid tabindex (without hyphen).

Since tab-index is not a recognized HTML attribute, the browser ignores it, leaving the hidden textarea in the tab order.

Docs on tabindex: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/tabindex

Steps to Reproduce

  1. Render any <TextArea autoSize /> component
  2. Tab through the page using keyboard navigation
  3. Observe that focus lands on an invisible textarea element

Expected Behavior

The hidden textarea should not be keyboard-focusable.

Actual Behavior

Users can tab to an invisible <textarea name="hiddenTextarea"> element, causing confusion for keyboard and screen reader users.

Root Cause

In src/calculateNodeHeight.tsx, line 102:

// Current (invalid HTML attribute)
hiddenTextarea.setAttribute('tab-index', '-1');

// Should be (valid HTML attribute)
hiddenTextarea.setAttribute('tabindex', '-1');

Impact

  • Accessibility: Screen reader users and keyboard navigators encounter an invisible, non-interactive element
  • User Experience: Unexpected "stop" when tabbing through form fields

Bug Origin

  • Introduced in: v0.2.0 (June 10, 2020)
  • Commit: fee4e45
  • Age: ~5.5 years

Proposed Fix

I have a PR ready with:

  1. One-character fix: tab-indextabindex
  2. Tests to verify hidden textarea has correct tabindex="-1" attribute

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions