Skip to content

Commit 722ad2d

Browse files
committed
Prevent closing the Combobox component when clicking inside the scrollbar area (#3104)
* prevent closing `Combobox` when clicking inside the scrollbar area * update changelog
1 parent be95227 commit 722ad2d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

packages/@headlessui-vue/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
- Nothing yet!
1111

12+
### Fixed
13+
14+
- Prevent closing the `Combobox` component when clicking inside the scrollbar area ([#3104](https://github.com/tailwindlabs/headlessui/pull/3104))
15+
1216
## [1.7.20] - 2024-04-15
1317

1418
### Fixed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,6 +1382,15 @@ export let ComboboxOptions = defineComponent({
13821382
},
13831383
})
13841384

1385+
/**
1386+
* Prevent focus from being lost if the user clicks on the scrollbar.
1387+
* Otherwise the `ComboboxInput` will lose focus and the combobox will
1388+
* close.
1389+
*/
1390+
function handleMouseDown(event: MouseEvent) {
1391+
event.preventDefault()
1392+
}
1393+
13851394
return () => {
13861395
let slot = { open: api.comboboxState.value === ComboboxStates.Open }
13871396
let ourProps = {
@@ -1390,6 +1399,7 @@ export let ComboboxOptions = defineComponent({
13901399
ref: api.optionsRef,
13911400
role: 'listbox',
13921401
'aria-multiselectable': api.mode.value === ValueMode.Multi ? true : undefined,
1402+
onMousedown: handleMouseDown,
13931403
}
13941404
let theirProps = omit(props, ['hold'])
13951405

0 commit comments

Comments
 (0)