Skip to content

Commit

Permalink
Merge pull request #19340 from guerler/consistent_help_popper
Browse files Browse the repository at this point in the history
Use popper wrapper for help text popover
  • Loading branch information
mvdbeek authored Dec 18, 2024
2 parents b74d24f + eda3b0e commit 4684800
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
11 changes: 5 additions & 6 deletions client/src/components/Help/HelpPopover.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<script setup lang="ts">
import { BPopover } from "bootstrap-vue";
import HelpTerm from "./HelpTerm.vue";
import Popper from "@/components/Popper/Popper.vue";
interface Props {
target: any;
target: HTMLElement;
term: string;
}
defineProps<Props>();
</script>

<template>
<BPopover v-if="target" :target="target" triggers="hover" placement="bottom">
<HelpTerm :term="term" />
</BPopover>
<Popper v-if="target" :reference-el="target" mode="light">
<HelpTerm :term="term" class="p-2" />
</Popper>
</template>
2 changes: 1 addition & 1 deletion client/src/components/Help/HelpTerm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const { loading, hasHelp, help } = useHelpForTerm(toRef(props, "term"));
<div v-if="loading">
<LoadingSpan message="Loading Galaxy help terms" />
</div>
<div v-else-if="hasHelp">
<div v-else-if="hasHelp && help">
<ConfigurationMarkdown :markdown="help" :admin="true" />
</div>
<div v-else>
Expand Down
12 changes: 5 additions & 7 deletions client/src/components/Help/HelpText.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script setup lang="ts">
import { ref } from "vue";
import HelpPopover from "./HelpPopover.vue";
interface Props {
Expand All @@ -10,17 +12,13 @@ interface Props {
withDefaults(defineProps<Props>(), {
forTitle: false,
});
const helpTarget = ref();
</script>

<template>
<span>
<HelpPopover
:target="
() => {
return $refs.helpTarget;
}
"
:term="uri" />
<HelpPopover :target="helpTarget" :term="uri" />
<span ref="helpTarget" class="help-text" :class="{ 'title-help-text': forTitle }">{{ text }}</span>
</span>
</template>
Expand Down
5 changes: 3 additions & 2 deletions client/src/components/Popper/Popper.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<span>
<span ref="reference">
<span v-if="!referenceEl" ref="reference">
<slot name="reference" />
</span>
<div v-show="visible" ref="popper" class="popper-element mt-1" :class="`popper-element-${mode}`">
Expand Down Expand Up @@ -33,11 +33,12 @@ const props = defineProps({
disabled: { type: Boolean, default: false },
mode: { type: String, default: "dark" },
placement: String as PropType<Placement>,
referenceEl: HTMLElement,
title: String,
trigger: String as PropType<Trigger>,
});
const reference = ref();
const reference = props.referenceEl ? ref(props.referenceEl) : ref();
const popper = ref();
const { visible } = usePopper(reference, popper, {
Expand Down
2 changes: 2 additions & 0 deletions client/src/components/Popper/usePopper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export function usePopper(
} else if (trigger === "hover") {
addEventListener(reference.value, "mouseover", doOpen);
addEventListener(reference.value, "mouseout", doClose);
addEventListener(popper.value, "mouseover", doOpen);
addEventListener(popper.value, "mouseout", doClose);
}
});

Expand Down

0 comments on commit 4684800

Please sign in to comment.