Skip to content

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

TypeScript

fix(input): forward native event handlers via ...rest spread (#1259) (#1291)

Cindy Zhangc681e203511f
diff --git a/packages/core/src/NumberInput/XDSNumberInput.tsx b/packages/core/src/NumberInput/XDSNumberInput.tsx
index 0e5466c13a..24dfcc9793 100644
--- a/packages/core/src/NumberInput/XDSNumberInput.tsx
+++ b/packages/core/src/NumberInput/XDSNumberInput.tsx
@@ -238,6 +238,10 @@ interface XDSNumberInputPropsBase extends Omit<
* Callback fired when the user presses the Enter key.
*/
onEnter?: () => void;
+ /**
+ * Callback fired on keydown events on the input.
+ */
+ onKeyDown?: (e: KeyboardEvent<HTMLInputElement>) => void;
}
/**
@@ -342,10 +346,12 @@ export function XDSNumberInput({
onBlur,
hasClear,
onEnter,
+ onKeyDown,
xstyle,
className,
style,
ref,
+ ...rest
}: XDSNumberInputProps) {
const id = useId();
const descriptionID = useId();
@@ -459,8 +465,18 @@ export function XDSNumberInput({
}
onEnter?.();
}
+ onKeyDown?.(e);
},
- [pendingInput, value, onChange, min, max, isIntegerOnly, onEnter],
+ [
+ pendingInput,
+ value,
+ onChange,
+ min,
+ max,
+ isIntegerOnly,
+ onEnter,
+ onKeyDown,
+ ],
);
// Combine refs
@@ -524,6 +540,7 @@ export function XDSNumberInput({
)}>
{startIcon && <XDSIcon icon={startIcon} size="sm" color="primary" />}
<input
+ {...rest}
ref={setRefs}
id={id}
name={htmlName}
diff --git a/packages/core/src/TextArea/XDSTextArea.tsx b/packages/core/src/TextArea/XDSTextArea.tsx
index cf6cbe694d..642a07ba4c 100644
--- a/packages/core/src/TextArea/XDSTextArea.tsx
+++ b/packages/core/src/TextArea/XDSTextArea.tsx
@@ -283,6 +283,7 @@ export function XDSTextArea({
className,
style,
ref,
+ ...rest
}: XDSTextAreaProps) {
const id = useId();
const descriptionID = useId();
@@ -367,6 +368,7 @@ export function XDSTextArea({
)}>
{startIcon && <XDSIcon icon={startIcon} size="sm" color="primary" />}
<textarea
+ {...rest}
ref={ref}
id={id}
name={htmlName}
diff --git a/packages/core/src/TextInput/XDSTextInput.tsx b/packages/core/src/TextInput/XDSTextInput.tsx
index 01321ac32a..cc4161d5de 100644
--- a/packages/core/src/TextInput/XDSTextInput.tsx
+++ b/packages/core/src/TextInput/XDSTextInput.tsx
@@ -253,6 +253,7 @@ export function XDSTextInput({
className,
style,
ref,
+ ...rest
}: XDSTextInputProps) {
const id = useId();
const descriptionID = useId();
@@ -354,6 +355,7 @@ export function XDSTextInput({
)}>
{startIcon && <XDSIcon icon={startIcon} size="sm" color="primary" />}
<input
+ {...rest}
ref={setRefs}
id={id}
name={htmlName}