Skip to content

Commit c2bf9dd

Browse files
authored
Prevent scrolling when focusing a tab (#2674)
* Prevent scrolling when focusing a tab * Update changelog
1 parent a317866 commit c2bf9dd

File tree

4 files changed

+4
-2
lines changed

4 files changed

+4
-2
lines changed

packages/@headlessui-react/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- Ensure `appear` works using the `Transition` component (even when used with SSR) ([#2646](https://github.com/tailwindlabs/headlessui/pull/2646))
1818
- Improve resetting values when using the `nullable` prop on the `Combobox` component ([#2660](https://github.com/tailwindlabs/headlessui/pull/2660))
1919
- Fix hydration of components inside `<Suspense>` ([#2663](https://github.com/tailwindlabs/headlessui/pull/2663))
20+
- Prevent scrolling when focusing a tab ([#2674](https://github.com/tailwindlabs/headlessui/pull/2674))
2021

2122
## [1.7.16] - 2023-07-27
2223

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ function TabFn<TTag extends ElementType = typeof DEFAULT_TAB_TAG>(
472472
if (ready.current) return
473473
ready.current = true
474474

475-
internalTabRef.current?.focus()
475+
internalTabRef.current?.focus({ preventScroll: true })
476476
actions.change(myIndex)
477477

478478
microTask(() => {

packages/@headlessui-vue/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- Improve SSR of the `Disclosure` component ([#2645](https://github.com/tailwindlabs/headlessui/pull/2645))
1818
- Fix incorrectly focused `ComboboxInput` component on page load ([#2654](https://github.com/tailwindlabs/headlessui/pull/2654))
1919
- Improve resetting values when using the `nullable` prop on the `Combobox` component ([#2660](https://github.com/tailwindlabs/headlessui/pull/2660))
20+
- Prevent scrolling when focusing a tab ([#2674](https://github.com/tailwindlabs/headlessui/pull/2674))
2021

2122
## [1.7.15] - 2023-07-27
2223

packages/@headlessui-vue/src/components/tabs/tabs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ export let Tab = defineComponent({
405405

406406
if (props.disabled) return
407407

408-
dom(internalTabRef)?.focus()
408+
dom(internalTabRef)?.focus({ preventScroll: true })
409409
api.setSelectedIndex(myIndex.value)
410410

411411
microTask(() => {

0 commit comments

Comments
 (0)