Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cant use u-avatar as triggers for u-popover #3710

Closed
Lionad-Morotar opened this issue Mar 28, 2025 · 1 comment · Fixed by #3712
Closed

cant use u-avatar as triggers for u-popover #3710

Lionad-Morotar opened this issue Mar 28, 2025 · 1 comment · Fixed by #3712
Labels
bug Something isn't working triage v3 #1289

Comments

@Lionad-Morotar
Copy link
Contributor

Environment

Is this bug related to Nuxt or Vue?

Nuxt

Version

v3

Reproduction

https://codesandbox.io/p/devbox/silent-currying-qhjsy6

Description

  • 当 Avatar 有图片内容时可以作为 UPopover 的 Trigger 被触发
  • 当 Avatar 展示子插槽内容,不能成功触发 UPopover

Additional context

No response

Logs

@Lionad-Morotar
Copy link
Contributor Author

Lionad-Morotar commented Mar 28, 2025

btw,如果不想等待或使用 patch 等其他方式更新依赖的开发者,可以使用组件手动管理继承的 attrs 属性来解决这个问题:

<template>
  <u-popover mode="hover" :class="ns.e('popover')">
    <p-inherit-attrs>
      <u-avatar>
        <p-slot>
          <p-icon :name="safeIcon(value)" />
        </p-slot>
      </u-avatar>
    </p-inherit-attrs>
    <template #content>
      content
    </template>
  </u-popover>
</template>
import { Fragment } from 'vue'
import { createContext } from 'reka-ui'

type InheritAttrsProps = null | Record<string, unknown>

export const [injectContext, provideContext]
  = createContext<InheritAttrsProps>('PInheritAttrs')

export default defineComponent({
  name: 'PInheritAttrs',
  inheritAttrs: false,
  setup(_, { attrs, slots }) {
    provideContext(attrs)

    return () => h(Fragment, {}, [slots.default?.()])
  },
})
import { injectContext } from "../p-inherit-attrs"
import { Slot } from 'reka-ui'

export default defineComponent({
  name: 'PSlot',
  inheritAttrs: false,
  setup(_, { attrs, slots }) {
    const inheritAttrs = injectContext(null)

    return () => h(Slot, inheritAttrs, slots)
  },
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage v3 #1289
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant