Skip to content

Commit

Permalink
fix(input): use native ref instead of custom ref
Browse files Browse the repository at this point in the history
  • Loading branch information
abelflopes committed Aug 9, 2024
1 parent ecc50da commit 23550f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions packages/components/input/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import React, { useEffect, useMemo } from "react";
import styles from "./styles/index.module.scss";
import React, {
type ComponentPropsWithRef,
type HTMLInputTypeAttribute,
useEffect,
useMemo,
} from "react";
import { useFormFieldContext, type FormFieldContextProps } from "@react-ck/form-field";
import classNames from "classnames";

export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "children"> {
export interface InputProps extends Omit<ComponentPropsWithRef<"input">, "children"> {
skin?: FormFieldContextProps["skin"];
/** Ref for the root element */
rootRef?: React.ForwardedRef<HTMLInputElement>;
}

/**
Expand All @@ -17,7 +20,6 @@ export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElem

export const Input = ({
skin,
rootRef,
id,
className,
...props
Expand All @@ -44,7 +46,6 @@ export const Input = ({
return (
<input
{...props}
ref={rootRef}
id={computedId}
className={classNames(
styles.root,
Expand Down
2 changes: 1 addition & 1 deletion packages/components/select/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ const Select = ({
placeholder={searchOptions.placeholder}
skin="ghost"
className={styles.search_input}
rootRef={(e) => {
ref={(e) => {
e?.focus();
}}
onChange={(e) => {
Expand Down

0 comments on commit 23550f5

Please sign in to comment.