-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Menubar, Megamenu, Contextmenu and etc.: Twice render if $attrs.id not defined #4953
Comments
Fixed in #4954 |
@i7slegend This PR broke our entire Id structure. Ids are constantly generated as undefined. That's why I reverted it. You can try your PR with Listbox demo;
For now, I set a milestone for it. We check it before the milestone is released. |
Got it. So i have test nuxt variant and see what beforeMount() not called on the server. I test the case with data() & beforeCreate() and found what it's called at same time (very very close) and it's affect to next problem: data() replace id to |
Attach code block (on example Listbox) which works under nuxt as expected: data() {
return {
id: this.$attrs.id || UniqueComponentId(),
filterValue: null,
focused: false,
focusedOptionIndex: -1
};
},
watch: {
'$attrs.id': function (newValue) {
this.id = newValue || UniqueComponentId();
},
options() {
this.autoUpdateModel();
}
},
mounted() {
this.autoUpdateModel();
}, |
Hi @i7slegend, Thanks a lot for the detailed info! Yes, we are working to update it like in the above code block. |
Hello! Sorry for reopen this issue, i found what commits above doesn't goals to fix trigger render twice in this issue's example. It's reproduces now I mean in the attached code block before (#4953 (comment)) this (use OR operator in state component for id property). data() {
return {
- id: this.$attrs.id,
+ id: this.$attrs.id || UniqueComponentId(),
filterValue: null,
focused: false,
focusedOptionIndex: -1
};
},
watch: {
'$attrs.id': function (newValue) {
this.id = newValue || UniqueComponentId();
},
options() {
this.autoUpdateModel();
}
},
mounted() {
- this.id = this.id || UniqueComponentId();
this.autoUpdateModel();
}, |
Oh, issue not reopened 😖 |
Describe the bug
Components like a menu (Menubar, Megamenu, Contextmenu) and another which generates id in the dom triggers "initial" render twice: first - with id null (if $attrs.id not passed), and next render with generated id
I got example with dirty fix in the codesandbox only with menubar
Reproducer
https://codesandbox.io/p/devbox/frosty-stitch-t2m2m9?file=%2Fsrc%2FApp.vue
PrimeVue version
3.43.0
Vue version
3.x
Language
ALL
Build / Runtime
Vite
Browser(s)
No response
Steps to reproduce the behavior
Create any component which generate id for DOM. All components what do it generate id after mount and trigger render twice also it's triggers submenus if child component uses id too
Expected behavior
Initial render trigger once (ofc if $attrs.id has not changed)
The text was updated successfully, but these errors were encountered: