Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/calculateNodeHeight.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -99,7 +99,7 @@ export default function calculateAutoSizeStyle(
): React.CSSProperties {
if (!hiddenTextarea) {
hiddenTextarea = document.createElement('textarea');
hiddenTextarea.setAttribute('tab-index', '-1');
hiddenTextarea.setAttribute('tabindex', '-1');
hiddenTextarea.setAttribute('aria-hidden', 'true');
// fix: A form field element should have an id or name attribute
// A form field element has neither an id nor a name attribute. This might prevent the browser from correctly autofilling the form.
Expand Down
11 changes: 11 additions & 0 deletions tests/TextArea.test.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,6 +96,17 @@ describe('TextArea', () => {
expect(textarea.value).toBe('222');
});

it('keeps the hidden measurement textarea out of the tab order', async () => {
render(<TextArea autoSize />);
await wait();

const measurementNode = document.querySelector(
'textarea[name="hiddenTextarea"]',
);
expect(measurementNode).toHaveAttribute('tabindex', '-1');
expect(measurementNode).not.toHaveAttribute('tab-index');
});

it('should auto calculate height according to content length and autoSize property', async () => {
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
const onInternalAutoSize = jest.fn();
Expand Down