Skip to content

Commit 4fc92a3

Browse files
authored
Fix arrow key navigation glitch (#28)
Fix: - When going down/up on in a second connection with identical topics as another previous one would scroll up to the first topic with that name
1 parent bffdc5e commit 4fc92a3

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/renderer/src/components/tap-topics/TopicItem.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ watch(
148148
<template>
149149
<div v-if="!isLastTopicPart" :id="`topic-item-${topicPath}`">
150150
<div class="tw-flex">
151-
<q-intersection :id="`topic-item-${topicPath}-intersection`" class="tw-h-[29px]">
151+
<q-intersection :id="`topic-item-${clientKey}:${topicPath}-intersection`" class="tw-h-[29px]">
152152
<topic-card
153153
ref="topicGroupTopicCardRef"
154154
expandable
@@ -196,7 +196,7 @@ watch(
196196
</template>
197197
</div>
198198
<div v-else class="tw-flex" :id="`topic-item-${topicPath}`">
199-
<q-intersection :id="`topic-item-${topicPath}-intersection`" class="tw-h-[29px]">
199+
<q-intersection :id="`topic-item-${clientKey}:${topicPath}-intersection`" class="tw-h-[29px]">
200200
<topic-card
201201
ref="topicCardRef"
202202
:has-actions="hasActions"

src/renderer/src/tabs/TabTopics.vue

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,13 @@ const handleKeyDown = (event: KeyboardEvent) => {
181181
}
182182
183183
const handleUpKeyDown = () => {
184+
const clientKey = mqttTopicsStore.selectedConnection
184185
const selectedTopicIndex = allTopics.value.indexOf(mqttTopicsStore.selectedTopic)
185186
const previousTopic = topicToSelect(selectedTopicIndex, 'up')
186187
187188
if (previousTopic) {
188189
handleSelectTopic(mqttTopicsStore.selectedConnection, previousTopic)
189-
handleScrollPreviousTopic(previousTopic)
190+
handleScrollPreviousTopic(clientKey, previousTopic)
190191
}
191192
192193
scrubbingTimeout.value = setTimeout(() => {
@@ -201,12 +202,13 @@ const handleUpKeyUp = () => {
201202
}
202203
203204
const handleDownKeyDown = () => {
205+
const clientKey = mqttTopicsStore.selectedConnection
204206
const selectedTopicIndex = allTopics.value.indexOf(mqttTopicsStore.selectedTopic)
205207
const nextTopic = topicToSelect(selectedTopicIndex, 'down')
206208
207209
if (nextTopic) {
208210
handleSelectTopic(mqttTopicsStore.selectedConnection, nextTopic)
209-
handleScrollNextTopic(nextTopic)
211+
handleScrollNextTopic(clientKey, nextTopic)
210212
}
211213
212214
scrubbingTimeout.value = setTimeout(() => {
@@ -233,7 +235,7 @@ const handleLeftKey = () => {
233235
234236
if (previousTopic) {
235237
handleSelectTopic(clientKey, previousTopic)
236-
handleScrollPreviousTopic(previousTopic)
238+
handleScrollPreviousTopic(clientKey, previousTopic)
237239
}
238240
}
239241
}
@@ -251,14 +253,14 @@ const handleRightKey = () => {
251253
252254
if (nextTopic) {
253255
handleSelectTopic(clientKey, nextTopic)
254-
handleScrollNextTopic(nextTopic)
256+
handleScrollNextTopic(clientKey, nextTopic)
255257
}
256258
}
257259
}
258260
259-
const handleScrollPreviousTopic = (previousTopic: string) => {
261+
const handleScrollPreviousTopic = (clientKey: string, previousTopic: string) => {
260262
const virtualScroll = document.getElementById('topicsVirtualScroll')
261-
const element = document.getElementById(`topic-item-${previousTopic}-intersection`)
263+
const element = document.getElementById(`topic-item-${clientKey}:${previousTopic}-intersection`)
262264
263265
if (virtualScroll && element) {
264266
if (element.offsetTop < virtualScroll.scrollTop) {
@@ -272,9 +274,9 @@ const handleScrollPreviousTopic = (previousTopic: string) => {
272274
}
273275
}
274276
275-
const handleScrollNextTopic = (nextTopic: string) => {
277+
const handleScrollNextTopic = (clientKey: string, nextTopic: string) => {
276278
const virtualScroll = document.getElementById('topicsVirtualScroll')
277-
const element = document.getElementById(`topic-item-${nextTopic}-intersection`)
279+
const element = document.getElementById(`topic-item-${clientKey}:${nextTopic}-intersection`)
278280
279281
if (virtualScroll && element) {
280282
if (

0 commit comments

Comments
 (0)