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

Vue 3 <script setup> syntax may cause the v-tooltip to break the whole Primevue's ZIndexUtils #2468

Closed
nndnha opened this issue Apr 20, 2022 · 4 comments

Comments

@nndnha
Copy link

nndnha commented Apr 20, 2022

I'm submitting a ... (check one with "x")

[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primevue/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=110

CodeSandbox Case (Bug Reports)
https://stackblitz.com/edit/github-hq9r6j?file=app.vue

What is the motivation / use case for changing the behavior?
Components with <script setup> syntax will make $primevue value undefined so the assigned value of this line of code will be undefined too, in that case the Primevue's ZIndexUtils system for Dialog, Overlay, Tooltip... will not work properly.

target.$_ptooltipZIndex = options.instance.$primevue && options.instance.$primevue.config && options.instance.$primevue.config.zIndex.tooltip;

@rubjo
Copy link
Contributor

rubjo commented Apr 25, 2022

@nndnha Thanks for discovering the cause of this, I too started wondering why some elements in my app seem to have the wrong z-index after a while.

Did you find any temporary workarounds while waiting for a fix?

@nndnha
Copy link
Author

nndnha commented Apr 25, 2022

@nndnha Thanks for discovering the cause of this, I too started wondering why some elements in my app seem to have the wrong z-index after a while.

Did you find any temporary workarounds while waiting for a fix?

I changed the tooltip directive setup code from:

import Tooltip from 'primevue/tooltip';

vueApp.directive('tooltip', Tooltip);

to:

import Tooltip from 'primevue/tooltip';
import { DomHandler } from "primevue/utils";

function getTarget(el) {
  return DomHandler.hasClass(el, "p-inputwrapper")
    ? DomHandler.findSingle(el, "input")
    : el;
}

vueApp.directive("tooltip", {
  mounted(el) {
    const target = getTarget(el);
    target.$_ptooltipZIndex ??=
      vueApp.config.globalProperties.$primevue.config.zIndex.tooltip;
  },
  ...Tooltip,
});

@cagataycivici cagataycivici added this to the 3.13.0 milestone May 31, 2022
@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label May 31, 2022
@mertsincan
Copy link
Member

mertsincan commented Jun 2, 2022

Hi,

I researched this issue and found a PR related to it in Vue core. It looks like it broke access to globalProperties variables and vnode's instances within those custom directives.
vuejs/core@f44087e

For now, you can use;

<script setup>
import { usePrimeVue } from "primevue/config";

const $primevue = usePrimeVue();
defineExpose({
     $primevue
})
</script>

Best Regards,

@LouisVA
Copy link

LouisVA commented Mar 22, 2023

Hi,

I researched this issue and found a PR related to it in Vue core. It looks like it broke access to globalProperties variables and vnode's instances within those custom directives. vuejs/core@f44087e

For now, you can use;

<script setup>
import { usePrimeVue } from "primevue/config";

const $primevue = usePrimeVue();
defineExpose({
     $primevue
})
</script>

Best Regards,

Can this be further explained?

I have tried to add this to components to fix my z-index not working. However this does not do anything. I must be using this wrong. Should this be added to every component? To App.vue too? Or just the component where we have the issue.

I have also tried changing the component back to <script> instead of <script setup> but that didn't do much either. I would need to do it to every component I guess?

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

No branches or pull requests

6 participants