Skip to content

Commit

Permalink
use isFocused in Input and Textarea
Browse files Browse the repository at this point in the history
We do this because we always want to show the focus ring regardless of
whether you used the mouse or the keyboard.
  • Loading branch information
RobinMalfait committed Jan 23, 2024
1 parent aff438e commit c543408
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
10 changes: 2 additions & 8 deletions packages/@headlessui-react/src/components/combobox/combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1317,10 +1317,7 @@ function InputFn<
let labelledBy = useLabelledBy()
let describedBy = useDescribedBy()

let { isFocusVisible: focus, focusProps } = useFocusRing({
isTextInput: true,
autoFocus: props.autoFocus ?? false,
})
let { isFocused: focus, focusProps } = useFocusRing({ autoFocus: props.autoFocus ?? false })
let { isHovered: hover, hoverProps } = useHover({ isDisabled: data.disabled ?? false })

let slot = useMemo(
Expand Down Expand Up @@ -1479,10 +1476,7 @@ function ButtonFn<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(

let labelledBy = useLabelledBy([id])

let { isFocusVisible: focus, focusProps } = useFocusRing({
isTextInput: true,
autoFocus: props.autoFocus ?? false,
})
let { isFocusVisible: focus, focusProps } = useFocusRing({ autoFocus: props.autoFocus ?? false })
let { isHovered: hover, hoverProps } = useHover({ isDisabled: data.disabled ?? false })
let { pressed: active, pressProps } = useActivePress({ disabled: data.disabled ?? false })

Expand Down
3 changes: 1 addition & 2 deletions packages/@headlessui-react/src/components/input/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ function InputFn<TTag extends ElementType = typeof DEFAULT_INPUT_TAG>(
let labelledBy = useLabelledBy()
let describedBy = useDescribedBy()

let { isFocusVisible: focus, focusProps } = useFocusRing({
isTextInput: true,
let { isFocused: focus, focusProps } = useFocusRing({
autoFocus: props.autoFocus ?? false,
})
let { isHovered: hover, hoverProps } = useHover({ isDisabled: disabled ?? false })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function TextareaFn<TTag extends ElementType = typeof DEFAULT_TEXTAREA_TAG>(
let labelledBy = useLabelledBy()
let describedBy = useDescribedBy()

let { isFocusVisible: focus, focusProps } = useFocusRing({ autoFocus: props.autoFocus ?? false })
let { isFocused: focus, focusProps } = useFocusRing({ autoFocus: props.autoFocus ?? false })
let { isHovered: hover, hoverProps } = useHover({ isDisabled: disabled ?? false })

let ourProps = mergeProps(
Expand Down

0 comments on commit c543408

Please sign in to comment.