Skip to content

About Menu Component's Async Popup Mode #7556

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

Open
k-0311 opened this issue Apr 1, 2025 · 2 comments · May be fixed by #7560
Open

About Menu Component's Async Popup Mode #7556

k-0311 opened this issue Apr 1, 2025 · 2 comments · May be fixed by #7560

Comments

@k-0311
Copy link

k-0311 commented Apr 1, 2025

When the Menu's model data is fetched through an API call before executing the show function, it causes event.currentTarget to be null.

Could we support passing a target parameter to the show function, similar to how the Popover component's show function works?

<script setup>
const menu = ref();
const items = ref();

const toggle = async (event: MouseEvent) => {
  const [data, _] = await Promise.all([
    () => [
      {
        label: 'Options',
        items: [
          {
            label: 'Refresh',
            icon: 'pi pi-refresh'
          },
          {
            label: 'Export',
            icon: 'pi pi-upload'
          }
        ]
      }
    ],
    sleep(1000),//Simulate asynchronous requests
  ])

  items.value = data

  menu.value.toggle(event);//event.currentTarget is null
};
</script>

<template>
  <div class="card flex justify-center">
      <Button type="button" icon="pi pi-ellipsis-v" @click="toggle" aria-haspopup="true" aria-controls="overlay_menu" />
      <Menu ref="menu" id="overlay_menu" :model="items" :popup="true" />
    </div>
</template>
</style>
@renqian805
Copy link

same issue

@wangziling
Copy link
Contributor

Hmmm...

🤣 Another solution is:

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants