Skip to content

Commit f2bc6fd

Browse files
authored
Use isFocused instead of isFocusVisible for Input and Textarea components (#2940)
* use `isFocused` in `Input` and `Textarea` We do this because we always want to show the focus ring regardless of whether you used the mouse or the keyboard. * update changelog
1 parent 3b2a102 commit f2bc6fd

File tree

4 files changed

+5
-11
lines changed

4 files changed

+5
-11
lines changed

packages/@headlessui-react/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Expose `disabled` state on `<Tab />` component ([#2918](https://github.com/tailwindlabs/headlessui/pull/2918))
1313
- Prevent default behaviour when clicking outside of a `Dialog.Panel` ([#2919](https://github.com/tailwindlabs/headlessui/pull/2919))
14+
- Use `isFocused` instead of `isFocusVisible` for `Input` and `Textarea` components ([#2940](https://github.com/tailwindlabs/headlessui/pull/2940))
1415

1516
## [2.0.0-alpha.4] - 2024-01-03
1617

packages/@headlessui-react/src/components/combobox/combobox.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,10 +1317,7 @@ function InputFn<
13171317
let labelledBy = useLabelledBy()
13181318
let describedBy = useDescribedBy()
13191319

1320-
let { isFocusVisible: focus, focusProps } = useFocusRing({
1321-
isTextInput: true,
1322-
autoFocus: props.autoFocus ?? false,
1323-
})
1320+
let { isFocused: focus, focusProps } = useFocusRing({ autoFocus: props.autoFocus ?? false })
13241321
let { isHovered: hover, hoverProps } = useHover({ isDisabled: data.disabled ?? false })
13251322

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

14801477
let labelledBy = useLabelledBy([id])
14811478

1482-
let { isFocusVisible: focus, focusProps } = useFocusRing({
1483-
isTextInput: true,
1484-
autoFocus: props.autoFocus ?? false,
1485-
})
1479+
let { isFocusVisible: focus, focusProps } = useFocusRing({ autoFocus: props.autoFocus ?? false })
14861480
let { isHovered: hover, hoverProps } = useHover({ isDisabled: data.disabled ?? false })
14871481
let { pressed: active, pressProps } = useActivePress({ disabled: data.disabled ?? false })
14881482

packages/@headlessui-react/src/components/input/input.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ function InputFn<TTag extends ElementType = typeof DEFAULT_INPUT_TAG>(
5656
let labelledBy = useLabelledBy()
5757
let describedBy = useDescribedBy()
5858

59-
let { isFocusVisible: focus, focusProps } = useFocusRing({
60-
isTextInput: true,
59+
let { isFocused: focus, focusProps } = useFocusRing({
6160
autoFocus: props.autoFocus ?? false,
6261
})
6362
let { isHovered: hover, hoverProps } = useHover({ isDisabled: disabled ?? false })

packages/@headlessui-react/src/components/textarea/textarea.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function TextareaFn<TTag extends ElementType = typeof DEFAULT_TEXTAREA_TAG>(
5656
let labelledBy = useLabelledBy()
5757
let describedBy = useDescribedBy()
5858

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

6262
let ourProps = mergeProps(

0 commit comments

Comments
 (0)