Skip to content

Commit 780d88a

Browse files
committed
fix: adding marcus' suggestions
1 parent 1def199 commit 780d88a

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

apps/docs/content/docs/components/input-otp.mdx

+6
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,12 @@ You can customize the styles of the `InputOtp` component using the `classNames`
303303
description: "Allows to set custom class names for the Input slots.",
304304
default: "-"
305305
},
306+
{
307+
attribute: "autoFocus",
308+
type: "boolean",
309+
description: "Whether the element should receive focus on render.",
310+
default: "false"
311+
},
306312
{
307313
attribute: "textAlign",
308314
type: "left | center | right",

packages/components/input-otp/__tests__/input-otp.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,15 @@ describe("InputOtp Component", () => {
169169
expect(onComplete).toHaveBeenCalledWith("1234");
170170
});
171171

172-
it("should autofocus when autofocus prop is passed.", async () => {
172+
it("should autofocus when autofocus prop is passed.", () => {
173173
// eslint-disable-next-line jsx-a11y/no-autofocus
174174
render(<InputOtp autoFocus length={4} />);
175175
const segments = screen.getAllByRole("presentation");
176176

177177
expect(segments[0]).toHaveAttribute("data-focus", "true");
178178
});
179179

180-
it("should not autofocus when autofocus prop is not passed.", async () => {
180+
it("should not autofocus when autofocus prop is not passed.", () => {
181181
render(<InputOtp length={4} />);
182182
const segments = screen.getAllByRole("presentation");
183183

packages/components/input-otp/src/use-input-otp.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ export function useInputOtp(originalProps: UseInputOtpProps) {
230230
ref: inputRef,
231231
name: name,
232232
value: value,
233-
autoFocus: originalProps.autoFocus,
233+
autoFocus,
234234
onChange: setValue,
235235
onBlur: chain(focusProps.onBlur, props?.onBlur),
236236
onComplete: onComplete,
@@ -255,6 +255,7 @@ export function useInputOtp(originalProps: UseInputOtpProps) {
255255
setValue,
256256
props.onBlur,
257257
onComplete,
258+
autoFocus,
258259
],
259260
);
260261

0 commit comments

Comments
 (0)