Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(TextArea,TimeInput): a11y and input consistency fixes (#1443)

Cindy Zhang91a20c96db4b
diff --git a/packages/core/src/TextArea/XDSTextArea.test.tsx b/packages/core/src/TextArea/XDSTextArea.test.tsx
index 0b988364be..99c5632a84 100644
--- a/packages/core/src/TextArea/XDSTextArea.test.tsx
+++ b/packages/core/src/TextArea/XDSTextArea.test.tsx
@@ -146,7 +146,7 @@ describe('XDSTextArea', () => {
expect(screen.getByRole('textbox')).not.toBeDisabled();
});
- it('is disabled when isLoading is true (isBusy)', () => {
+ it('shows aria-busy when isLoading is true', () => {
render(
<XDSTextArea
label="Description"
@@ -155,7 +155,8 @@ describe('XDSTextArea', () => {
onChange={() => {}}
/>,
);
- expect(screen.getByRole('textbox')).toBeDisabled();
+ expect(screen.getByRole('textbox')).toHaveAttribute('aria-busy', 'true');
+ expect(screen.getByRole('textbox')).not.toBeDisabled();
});
it('does not call onChange when disabled', async () => {
diff --git a/packages/core/src/TextArea/XDSTextArea.tsx b/packages/core/src/TextArea/XDSTextArea.tsx
index 47adc15801..970271b3c6 100644
--- a/packages/core/src/TextArea/XDSTextArea.tsx
+++ b/packages/core/src/TextArea/XDSTextArea.tsx
@@ -378,7 +378,7 @@ export function XDSTextArea({
onBlur={onBlur}
placeholder={placeholder}
rows={rows}
- disabled={effectivelyDisabled}
+ disabled={isDisabled}
spellCheck={hasSpellCheck}
autoFocus={hasAutoFocus}
data-autofocus={hasAutoFocus || undefined}
diff --git a/packages/core/src/TimeInput/XDSTimeInput.tsx b/packages/core/src/TimeInput/XDSTimeInput.tsx
index 8e94db3021..41ffc30d8d 100644
--- a/packages/core/src/TimeInput/XDSTimeInput.tsx
+++ b/packages/core/src/TimeInput/XDSTimeInput.tsx
@@ -211,6 +211,12 @@ export interface XDSTimeInputProps {
*/
hasClear?: boolean;
+ /**
+ * Whether to automatically focus the input on mount.
+ * @default false
+ */
+ hasAutoFocus?: boolean;
+
/**
* Hour format for display.
* - '12h': Display as 12-hour with AM/PM (e.g., "2:30 PM")
@@ -303,6 +309,7 @@ export function XDSTimeInput({
max,
hasSeconds = false,
hasClear = false,
+ hasAutoFocus = false,
hourFormat = '12h',
increment = 1,
placeholder = 'Select a time',
@@ -552,6 +559,8 @@ export function XDSTimeInput({
onKeyDown={handleInputKeyDown}
placeholder={displayPlaceholder}
disabled={isDisabled}
+ autoFocus={hasAutoFocus}
+ data-autofocus={hasAutoFocus || undefined}
aria-describedby={ariaDescribedBy}
aria-required={isRequired === true ? 'true' : undefined}
aria-invalid={status?.type === 'error' ? 'true' : undefined}