Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/components/Package/MetricsBadges.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const typesHref = computed(() => {
<ul class="flex items-center gap-1.5 list-none m-0 p-0">
<!-- TypeScript types badge -->
<li v-if="!props.isBinary" class="contents">
<TooltipApp :text="typesTooltip">
<TooltipApp :text="typesTooltip" strategy="fixed">
<LinkBase
v-if="typesHref"
variant="button-secondary"
Expand Down Expand Up @@ -88,6 +88,7 @@ const typesHref = computed(() => {
<li class="contents">
<TooltipApp
:text="isLoading ? '' : hasEsm ? $t('package.metrics.esm') : $t('package.metrics.no_esm')"
strategy="fixed"
>
<TagStatic
tabindex="0"
Expand All @@ -107,7 +108,7 @@ const typesHref = computed(() => {

<!-- CJS badge -->
<li v-if="isLoading || hasCjs" class="contents">
<TooltipApp :text="isLoading ? '' : $t('package.metrics.cjs')">
<TooltipApp :text="isLoading ? '' : $t('package.metrics.cjs')" strategy="fixed">
<TagStatic
tabindex="0"
:variant="isLoading ? 'ghost' : 'default'"
Expand Down
6 changes: 5 additions & 1 deletion app/components/Tooltip/Base.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import type { Placement } from '@floating-ui/vue'
import type { Placement, Strategy } from '@floating-ui/vue'
import { autoUpdate, flip, offset, shift, useFloating } from '@floating-ui/vue'

const props = withDefaults(
Expand All @@ -17,9 +17,12 @@ const props = withDefaults(
tooltipAttr?: HTMLAttributes
/** Teleport target for the tooltip content (defaults to 'body') */
to?: string | HTMLElement
/** Strategy for the tooltip - prefer fixed for sticky containers (defaults to 'absolute') */
strategy?: Strategy
}>(),
{
to: 'body',
strategy: 'absolute',
},
)

Expand All @@ -31,6 +34,7 @@ const placement = computed<Placement>(() => props.position || 'bottom')
const { floatingStyles } = useFloating(triggerRef, tooltipRef, {
placement,
whileElementsMounted: autoUpdate,
strategy: props.strategy,
middleware: [offset(4), flip(), shift({ padding: 8 })],
})
</script>
Expand Down
2 changes: 2 additions & 0 deletions app/pages/package/[[org]]/[name].vue
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ onKeyStroke(
: $t('package.verified_provenance')
"
position="bottom"
strategy="fixed"
>
<LinkBase
variant="button-secondary"
Expand Down Expand Up @@ -696,6 +697,7 @@ onKeyStroke(
"
position="bottom"
class="items-center"
strategy="fixed"
>
<ButtonBase
@click="likeAction"
Expand Down
Loading