Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure clicking a ComboboxOption after filtering the options, correctly triggers a change #3180

Merged
merged 8 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/@headlessui-vue/src/hooks/use-disposables.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { onUnmounted } from 'vue'
import { disposables } from '../utils/disposables'

/**
* The `useDisposables` hook returns a `disposables` object that is disposed
* when the component is unmounted.
*/
export function useDisposables() {
let d = disposables()
onUnmounted(() => d.dispose())
return d
}
17 changes: 17 additions & 0 deletions packages/@headlessui-vue/src/hooks/use-frame-debounce.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useDisposables } from './use-disposables'

/**
* Schedule some task in the next frame.
*
* - If you call the returned function multiple times, only the last task will
* be executed.
* - If the component is unmounted, the task will be cancelled.
*/
export function useFrameDebounce() {
let d = useDisposables()

return (cb: () => void) => {
d.dispose()
d.nextFrame(() => cb())
thecrypticace marked this conversation as resolved.
Show resolved Hide resolved
}
}
4 changes: 4 additions & 0 deletions packages/@headlessui-vue/src/mouse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum MouseButton {
Left = 0,
Right = 2,
}