Merge pull request #3463 from primefaces/issue-3166

PanelMenu: passing computed value as a model prop fixed
pull/3518/head^2
Bahadır 2023-01-10 11:35:09 +03:00 committed by GitHub
commit d9244f66a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

5
components/panelmenu/PanelMenu.vue Executable file → Normal file
View File

@ -73,6 +73,7 @@ export default {
activeItem: null activeItem: null
}; };
}, },
methods: { methods: {
getItemProp(item, name) { getItemProp(item, name) {
return item ? ObjectUtils.getItemValue(item[name]) : undefined; return item ? ObjectUtils.getItemValue(item[name]) : undefined;
@ -81,7 +82,7 @@ export default {
return this.getItemProp(item, 'label'); return this.getItemProp(item, 'label');
}, },
isItemActive(item) { isItemActive(item) {
return this.expandedKeys ? this.expandedKeys[this.getItemProp(item, 'key')] : item === this.activeItem; return this.expandedKeys ? this.expandedKeys[this.getItemProp(item, 'key')] : ObjectUtils.equals(item, this.activeItem);
}, },
isItemVisible(item) { isItemVisible(item) {
return this.getItemProp(item, 'visible') !== false; return this.getItemProp(item, 'visible') !== false;
@ -202,7 +203,7 @@ export default {
const active = this.isItemActive(item); const active = this.isItemActive(item);
const eventName = !active ? 'panel-open' : 'panel-close'; const eventName = !active ? 'panel-open' : 'panel-close';
this.activeItem = selfActive ? item : this.activeItem && this.activeItem === item ? null : item; this.activeItem = selfActive ? item : this.activeItem && ObjectUtils.equals(item, this.activeItem) ? null : item;
this.changeExpandedKeys({ item, expanded: !active }); this.changeExpandedKeys({ item, expanded: !active });
this.$emit(eventName, { originalEvent: event, item }); this.$emit(eventName, { originalEvent: event, item });
} }