Skip to content

Commit f7d7438

Browse files
committed
feat: allow subscribing for the InputEvent in the TextField component
1 parent 9480fbb commit f7d7438

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/keybr-widget/lib/components/textfield/TextField.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const TextField = forwardRef(function TextField(
2323
type = "text",
2424
value,
2525
onChange,
26+
onInput,
2627
...props
2728
}: TextFieldProps,
2829
ref: ForwardedRef<TextFieldRef>,
@@ -59,11 +60,15 @@ export const TextField = forwardRef(function TextField(
5960
onChange={(event) => {
6061
onChange?.((event.target as HTMLTextAreaElement).value);
6162
}}
63+
onInput={({ nativeEvent }) => {
64+
onInput?.(nativeEvent as InputEvent);
65+
}}
6266
/>
6367
);
6468
} else {
6569
return (
6670
<input
71+
{...props}
6772
ref={element as RefObject<HTMLInputElement>}
6873
className={clsx(
6974
styles.root,
@@ -81,7 +86,9 @@ export const TextField = forwardRef(function TextField(
8186
onChange={(event) => {
8287
onChange?.((event.target as HTMLInputElement).value);
8388
}}
84-
{...props}
89+
onInput={({ nativeEvent }) => {
90+
onInput?.(nativeEvent as InputEvent);
91+
}}
8592
/>
8693
);
8794
}

packages/keybr-widget/lib/components/textfield/TextField.types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export type TextFieldProps = {
1818
readonly type?: TextFieldType;
1919
readonly value?: string;
2020
readonly onChange?: (value: string) => void;
21+
readonly onInput?: (event: InputEvent) => void;
2122
} & FocusProps &
2223
MouseProps &
2324
KeyboardProps;

0 commit comments

Comments
 (0)