Skip to content

Commit 62306d7

Browse files
authored
Open first endpoint when opening .zap file (#1673)
- When no endpoint is selected and this.endpointIdListSorted is available then choose the first endpoint in it - JIRA: ZAPP-1500
1 parent 512a4e5 commit 62306d7

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

src/components/ZclEndpointCard.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,19 @@ export default {
604604
this.selectedAttributes = []
605605
this.selectedReporting = []
606606
this.getEndpointCardData()
607-
//only show Matter features if Matter is selected
607+
}
608+
},
609+
610+
mounted() {
611+
// If this endpoint is selected when mounted, expand it with a delay to trigger animation
612+
if (this.isSelectedEndpoint) {
613+
// Use setTimeout to ensure the transition can detect the change
614+
setTimeout(() => {
615+
this.$store.commit('zap/toggleShowEndpoint', {
616+
id: this.endpointReference,
617+
value: true
618+
})
619+
}, 50)
608620
}
609621
}
610622
}

src/components/ZclEndpointManager.vue

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,15 @@ export default {
6060
mixins: [CommonMixin],
6161
mounted() {
6262
// initialize ZclClusterManager with first endpoint info.
63-
if (this.endpointIdListSorted.size && !this.selectedEndpointId) {
64-
this.setSelectedEndpointType(
65-
this.endpointIdListSorted.keys().next().value
66-
)
63+
this.ensureEndpointSelected()
64+
},
65+
watch: {
66+
endpoints: {
67+
handler() {
68+
// Auto-select first endpoint when endpoints are loaded
69+
this.ensureEndpointSelected()
70+
},
71+
immediate: true
6772
}
6873
},
6974
computed: {
@@ -106,6 +111,17 @@ export default {
106111
// This function changing the modal state
107112
toggleCreateEndpointModal() {
108113
this.$store.commit('zap/toggleEndpointModal', true)
114+
},
115+
// Auto-select the first endpoint if no endpoint is currently selected
116+
ensureEndpointSelected() {
117+
if (
118+
this.endpointIdListSorted.size > 0 &&
119+
(this.selectedEndpointId == null ||
120+
this.selectedEndpointId === undefined)
121+
) {
122+
const firstEndpointId = this.endpointIdListSorted.keys().next().value
123+
this.setSelectedEndpointType(firstEndpointId)
124+
}
109125
}
110126
}
111127
}

0 commit comments

Comments
 (0)