Skip to content

Commit 51f0f11

Browse files
simula-rJake Schroeder
andauthored
refactor: remove unused tooltip appendTo code (#5943)
## Summary Remove unused tooltip appendTo positioning code. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5943-refactor-remove-unused-tooltip-appendTo-code-2846d73d365081d99c00cd41e35eb496) by [Unito](https://www.unito.io) --------- Co-authored-by: Jake Schroeder <[email protected]>
1 parent d69c548 commit 51f0f11

File tree

7 files changed

+20
-55
lines changed

7 files changed

+20
-55
lines changed

src/renderer/extensions/vueNodes/components/InputSlot.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
<script setup lang="ts">
2828
import {
2929
type ComponentPublicInstance,
30-
type Ref,
3130
computed,
32-
inject,
3331
onErrorCaptured,
3432
ref,
3533
watchEffect
@@ -86,11 +84,8 @@ const labelClasses = computed(() =>
8684
const renderError = ref<string | null>(null)
8785
const { toastErrorHandler } = useErrorHandling()
8886
89-
const tooltipContainer =
90-
inject<Ref<HTMLElement | undefined>>('tooltipContainer')
9187
const { getInputSlotTooltip, createTooltipConfig } = useNodeTooltips(
92-
props.nodeType || '',
93-
tooltipContainer
88+
props.nodeType || ''
9489
)
9590
9691
const tooltipConfig = computed(() => {

src/renderer/extensions/vueNodes/components/LGraphNode.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118

119119
<script setup lang="ts">
120120
import { storeToRefs } from 'pinia'
121-
import { computed, inject, onErrorCaptured, onMounted, provide, ref } from 'vue'
121+
import { computed, inject, onErrorCaptured, onMounted, ref } from 'vue'
122122
123123
import type { VueNodeData } from '@/composables/graph/useGraphNodeManager'
124124
import { toggleNodeOptions } from '@/composables/graph/useMoreOptionsMenu'
@@ -371,5 +371,4 @@ const nodeMedia = computed(() => {
371371
})
372372
373373
const nodeContainerRef = ref()
374-
provide('tooltipContainer', nodeContainerRef)
375374
</script>

src/renderer/extensions/vueNodes/components/NodeHeader.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ const createMountConfig = () => {
101101
updated: vi.fn(),
102102
unmounted: vi.fn()
103103
}
104-
},
105-
provide: {
106-
tooltipContainer: { value: document.createElement('div') }
107104
}
108105
}
109106
}

src/renderer/extensions/vueNodes/components/NodeHeader.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
</template>
6363

6464
<script setup lang="ts">
65-
import { type Ref, computed, inject, onErrorCaptured, ref, watch } from 'vue'
65+
import { computed, onErrorCaptured, ref, watch } from 'vue'
6666
6767
import IconButton from '@/components/button/IconButton.vue'
6868
import EditableText from '@/components/common/EditableText.vue'
@@ -108,11 +108,8 @@ onErrorCaptured((error) => {
108108
// Editing state
109109
const isEditing = ref(false)
110110
111-
const tooltipContainer =
112-
inject<Ref<HTMLElement | undefined>>('tooltipContainer')
113111
const { getNodeDescription, createTooltipConfig } = useNodeTooltips(
114-
nodeData?.type || '',
115-
tooltipContainer
112+
nodeData?.type || ''
116113
)
117114
118115
const tooltipConfig = computed(() => {

src/renderer/extensions/vueNodes/components/NodeWidgets.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
</template>
5353

5454
<script setup lang="ts">
55-
import { type Ref, computed, inject, onErrorCaptured, ref } from 'vue'
55+
import { computed, onErrorCaptured, ref } from 'vue'
5656
5757
import type {
5858
SafeWidgetData,
@@ -98,11 +98,8 @@ onErrorCaptured((error) => {
9898
})
9999
100100
const nodeType = computed(() => nodeData?.type || '')
101-
const tooltipContainer =
102-
inject<Ref<HTMLElement | undefined>>('tooltipContainer')
103101
const { getWidgetTooltip, createTooltipConfig } = useNodeTooltips(
104-
nodeType.value,
105-
tooltipContainer
102+
nodeType.value
106103
)
107104
108105
interface ProcessedWidget {

src/renderer/extensions/vueNodes/components/OutputSlot.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
<script setup lang="ts">
2525
import {
2626
type ComponentPublicInstance,
27-
type Ref,
2827
computed,
29-
inject,
3028
onErrorCaptured,
3129
ref,
3230
watchEffect
@@ -60,11 +58,8 @@ const renderError = ref<string | null>(null)
6058
6159
const { toastErrorHandler } = useErrorHandling()
6260
63-
const tooltipContainer =
64-
inject<Ref<HTMLElement | undefined>>('tooltipContainer')
6561
const { getOutputSlotTooltip, createTooltipConfig } = useNodeTooltips(
66-
props.nodeType || '',
67-
tooltipContainer
62+
props.nodeType || ''
6863
)
6964
7065
const tooltipConfig = computed(() => {

src/renderer/extensions/vueNodes/composables/useNodeTooltips.ts

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import type { TooltipDirectivePassThroughOptions } from 'primevue'
2-
import { type MaybeRef, type Ref, computed, ref, unref } from 'vue'
1+
import type {
2+
TooltipDirectivePassThroughOptions,
3+
TooltipPassThroughMethodOptions
4+
} from 'primevue/tooltip'
5+
import { type MaybeRef, computed, ref, unref } from 'vue'
36

47
import type { SafeWidgetData } from '@/composables/graph/useGraphNodeManager'
58
import { st } from '@/i18n'
@@ -77,10 +80,7 @@ function setupGlobalTooltipHiding() {
7780
* Composable for managing Vue node tooltips
7881
* Provides tooltip text for node headers, slots, and widgets
7982
*/
80-
export function useNodeTooltips(
81-
nodeType: MaybeRef<string>,
82-
containerRef?: Ref<HTMLElement | undefined>
83-
) {
83+
export function useNodeTooltips(nodeType: MaybeRef<string>) {
8484
const nodeDefStore = useNodeDefStore()
8585
const settingsStore = useSettingStore()
8686

@@ -151,14 +151,7 @@ export function useNodeTooltips(
151151
const tooltipDelay = settingsStore.get('LiteGraph.Node.TooltipDelay')
152152
const tooltipText = text || ''
153153

154-
const config: {
155-
value: string
156-
showDelay: number
157-
hideDelay: number
158-
disabled: boolean
159-
appendTo?: HTMLElement
160-
pt?: TooltipDirectivePassThroughOptions
161-
} = {
154+
return {
162155
value: tooltipText,
163156
showDelay: tooltipDelay as number,
164157
hideDelay: 0, // Immediate hiding
@@ -172,24 +165,16 @@ export function useNodeTooltips(
172165
class:
173166
'border-sand-100 bg-pure-white dark-theme:bg-charcoal-800 border dark-theme:border-slate-300 rounded-md px-4 py-2 text-charcoal-700 dark-theme:text-pure-white text-sm font-normal leading-tight max-w-75 shadow-none'
174167
},
175-
arrow: ({ context }) => ({
168+
arrow: ({ context }: TooltipPassThroughMethodOptions) => ({
176169
class: cn(
177-
context?.top && 'border-t-sand-100 dark-theme:border-t-slate-300',
178-
context?.bottom &&
179-
'border-b-sand-100 dark-theme:border-b-slate-300',
180-
context?.left && 'border-l-sand-100 dark-theme:border-l-slate-300',
181-
context?.right && 'border-r-sand-100 dark-theme:border-r-slate-300'
170+
context.top && 'border-t-sand-100 dark-theme:border-t-slate-300',
171+
context.bottom && 'border-b-sand-100 dark-theme:border-b-slate-300',
172+
context.left && 'border-l-sand-100 dark-theme:border-l-slate-300',
173+
context.right && 'border-r-sand-100 dark-theme:border-r-slate-300'
182174
)
183175
})
184-
}
185-
}
186-
187-
// If we have a container reference, append tooltips to it
188-
if (containerRef?.value) {
189-
config.appendTo = containerRef.value
176+
} as TooltipDirectivePassThroughOptions
190177
}
191-
192-
return config
193178
}
194179

195180
return {

0 commit comments

Comments
 (0)