Skip to content

Commit

Permalink
fix(web-core): tooltip position does not update when content changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ByScripts committed Sep 10, 2024
1 parent 790ba9b commit 821ca90
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions @xen-orchestra/web-core/lib/components/tooltip/TooltipItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { TooltipOptions } from '@core/stores/tooltip.store'
import { hasEllipsis } from '@core/utils/has-ellipsis.util'
import { isString } from 'lodash-es'
import place from 'placement.js'
import { computed, ref, watchEffect } from 'vue'
import { computed, ref, watch, watchEffect } from 'vue'

const props = defineProps<{
target: HTMLElement
Expand Down Expand Up @@ -41,13 +41,19 @@ const isDisabled = computed(() => content.value === false)

const placement = computed(() => props.options.placement ?? 'top')

watchEffect(() => {
if (tooltipElement.value) {
place(props.target, tooltipElement.value, {
placement: placement.value,
})
function updatePlacement() {
if (!tooltipElement.value) {
return
}
})

place(props.target, tooltipElement.value, {
placement: placement.value,
})
}

watchEffect(() => updatePlacement(), { flush: 'post' })

watch(content, () => updatePlacement(), { flush: 'post' })
</script>

<style lang="postcss" scoped>
Expand Down

0 comments on commit 821ca90

Please sign in to comment.