Here's the basic code to accomplish this:
Code: Select all
<template>
<div
ref="container"
@mouseover="hovering.value = true"
@mouseleave="hovering.value = false"
>
<!-- content not relevant -->
<someOtherComponent />
<div v-if="hovering">
<SplitButton
:append-to="container"
:model="addItemOptions"
label="Add Symbol"
@click="addNewSymbol"
/>
</div>
</div>
</template>
<script lang="ts" setup>
import SplitButton from "primevue/splitbutton";
import { ref, watch } from "vue";
// ref for container div
const container = ref<HTMLElement>();
// hovering state
const hovering = ref(false);
// options for SplitButton
const addItemOptions = [{
label: "Label1",
command: someFunc1,
}, {
label: "Label2",
command: someFunc2,
}, {
label: "Label3",
command: someFunc3,
}
];
</script>
Code: Select all
[Vue warn]: Invalid prop: type check failed for prop "appendTo". Expected String with value "[object HTMLDivElement]", got HTMLDivElement
...
[Vue warn]: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core
...
Code: Select all
Uncaught (in promise) DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.