File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
src/components/dls/Button Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,13 @@ export enum ButtonVariant {
4242 Accent = 'accent' ,
4343}
4444
45+ /**
46+ * Props for the Button component.
47+ *
48+ * **Important**: When `href` is provided, the component renders a `<Link>` with a `<div>` inside instead of a `<button>`.
49+ * In this case, the `ref` parameter will not be forwarded and will be `null` when accessed by consumers.
50+ * If you need to access the underlying element via ref, avoid using the `href` prop.
51+ */
4552export type ButtonProps = {
4653 size ?: ButtonSize ;
4754 shape ?: ButtonShape ;
@@ -68,6 +75,14 @@ export type ButtonProps = {
6875 id ?: string ;
6976} ;
7077
78+ /**
79+ * Button component that can render as either a button or a link.
80+ *
81+ * @param ref - Forwarded ref to the underlying button element.
82+ * **Important**: When `href` is provided, the component renders a `<Link>` with a `<div>` inside,
83+ * and the ref will not be forwarded. In this scenario, accessing the ref will return `null`.
84+ * If you need ref access, avoid using the `href` prop.
85+ */
7186const Button = forwardRef < HTMLButtonElement , ButtonProps > (
7287 (
7388 {
@@ -169,7 +184,7 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(
169184 < button
170185 ref = { ref }
171186 // eslint-disable-next-line react/button-has-type
172- type = { htmlType }
187+ type = { htmlType || 'button' }
173188 dir = { direction }
174189 className = { classes }
175190 disabled = { disabled }
You can’t perform that action at this time.
0 commit comments