Panelmenu review fixes

pull/3463/head
Bahadır Sofuoğlu 2023-01-03 12:14:46 +03:00
parent 5888f1d9e9
commit 9eee09834e
1 changed files with 4 additions and 11 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div :id="id" class="p-panelmenu p-component"> <div :id="id" class="p-panelmenu p-component">
<template v-for="(item, index) of items" :key="getPanelKey(index)"> <template v-for="(item, index) of model" :key="getPanelKey(index)">
<div v-if="isItemVisible(item)" :style="getItemProp(item, 'style')" :class="getPanelClass(item)"> <div v-if="isItemVisible(item)" :style="getItemProp(item, 'style')" :class="getPanelClass(item)">
<div <div
:id="getHeaderId(index)" :id="getHeaderId(index)"
@ -74,14 +74,7 @@ export default {
items: null items: null
}; };
}, },
watch: {
model: {
immediate: true,
handler(newValue) {
this.items = reactive(newValue);
}
}
},
methods: { methods: {
getItemProp(item, name) { getItemProp(item, name) {
return item ? ObjectUtils.getItemValue(item[name]) : undefined; return item ? ObjectUtils.getItemValue(item[name]) : undefined;
@ -90,7 +83,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.deepEquals(item, this.activeItem);
}, },
isItemVisible(item) { isItemVisible(item) {
return this.getItemProp(item, 'visible') !== false; return this.getItemProp(item, 'visible') !== false;
@ -208,7 +201,7 @@ export default {
}, },
changeActiveItem(event, item, selfActive = false) { changeActiveItem(event, item, selfActive = false) {
if (!this.isItemDisabled(item)) { if (!this.isItemDisabled(item)) {
this.activeItem = selfActive ? item : this.activeItem && this.activeItem === item ? null : item; this.activeItem = selfActive ? item : this.activeItem && ObjectUtils.deepEquals(item, this.activeItem) ? null : item;
const active = this.isItemActive(item); const active = this.isItemActive(item);
const eventName = active ? 'panel-open' : 'panel-close'; const eventName = active ? 'panel-open' : 'panel-close';