Skip to content

Commit

Permalink
feat(Tooltip): add new directive
Browse files Browse the repository at this point in the history
closes #9610
  • Loading branch information
johnleider committed Mar 8, 2024
1 parent 03759b1 commit 9e66f2a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/vuetify/src/composables/directiveComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ export const useDirectiveComponent = (

return {
mounted (el: HTMLElement, binding: DirectiveBinding, vnode: VNode) {
const { value } = binding
const text = binding.value?.text ?? binding.value
const value = Object(binding.value) === binding.value ? binding.value : undefined

// Get the children from the props or directive value, or the element's children
const children = props.text || value.text || el.innerHTML
const children = () => text || el.innerHTML

// If vnode.ctx is the same as the instance, then we're bound to a plain element
// and need to find the nearest parent component instance to inherit provides from
Expand Down
1 change: 1 addition & 0 deletions packages/vuetify/src/directives/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export { Resize } from './resize'
export { Ripple } from './ripple'
export { Scroll } from './scroll'
export { Touch } from './touch'
export { Tooltip } from './tooltip'
11 changes: 11 additions & 0 deletions packages/vuetify/src/directives/tooltip/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Components
import { VTooltip } from '@/components/VTooltip'

// Composables
import { useDirectiveComponent } from '@/composables/directiveComponent'

export const Tooltip = useDirectiveComponent(VTooltip, {
activator: 'parent',
})

export default Tooltip

0 comments on commit 9e66f2a

Please sign in to comment.