Skip to content

Commit

Permalink
fix infinite loop when using <Button as={Fragment}>
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed Sep 12, 2024
1 parent 61bba65 commit 793e454
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/@headlessui-react/src/components/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
forwardRefWithAs,
mergeProps,
render,
useMergeRefsFn,
type HasDisplayName,
type RefProp,
} from '../../utils/render'
Expand Down Expand Up @@ -41,6 +42,7 @@ function ButtonFn<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(
ref: Ref<HTMLElement>
) {
let providedDisabled = useDisabled()
let mergeRefs = useMergeRefsFn()
let { disabled = providedDisabled || false, autoFocus = false, ...theirProps } = props

let { isFocusVisible: focus, focusProps } = useFocusRing({ autoFocus })
Expand All @@ -64,6 +66,7 @@ function ButtonFn<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(
}, [disabled, hover, focus, active, autoFocus])

return render({
mergeRefs,
ourProps,
theirProps,
slot,
Expand Down

0 comments on commit 793e454

Please sign in to comment.