Skip to content

Commit e80e189

Browse files
nemphyscursoragent
andcommitted
fix: improve card open performance on boards with many cards
Signed-off-by: Dimitris Kazakos <nemphys@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 9fa3e5b commit e80e189

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

src/components/cards/CardItem.vue

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<template>
77
<AttachmentDragAndDrop v-if="card" :card-id="card.id" class="drop-upload--card">
88
<div :ref="`card${card.id}`"
9-
:class="{'compact': compactMode, 'current-card': currentCard, 'no-labels': !hasLabels, 'card__editable': canEdit, 'card__archived': card.archived, 'card__highlight': highlight}"
9+
:class="{'compact': compactMode, 'current-card': isCurrentCard, 'no-labels': !hasLabels, 'card__editable': canEdit, 'card__archived': card.archived, 'card__highlight': highlight}"
1010
:style="{backgroundColor: color}"
1111
tag="div"
1212
:tabindex="0"
@@ -48,15 +48,13 @@
4848
</div>
4949

5050
<div v-if="hasLabels" class="card-labels">
51-
<transition-group v-if="card.labels && card.labels.length"
52-
name="zoom"
53-
tag="ul"
51+
<ul v-if="card.labels && card.labels.length"
5452
class="labels"
5553
@click.stop="openCard">
5654
<li v-for="label in labelsSorted" :key="label?.id ?? label?.title" :style="labelStyle(label)">
5755
<span @click.stop="applyLabelFilter(label)">{{ label.title }}</span>
5856
</li>
59-
</transition-group>
57+
</ul>
6058
<CardMenu v-if="showMenuAtLabels"
6159
:card="card"
6260
class="right"
@@ -125,6 +123,7 @@ export default {
125123
return {
126124
highlight: false,
127125
editingTitle: TITLE_EDITING_STATE.OFF,
126+
isCurrentCard: false,
128127
}
129128
},
130129
computed: {
@@ -158,9 +157,6 @@ export default {
158157
const reference = this.card?.referenceData
159158
return reference ? reference.openGraphObject.name : this.card.title
160159
},
161-
currentCard() {
162-
return this.card && this.$route && this.$route.params.cardId === this.card.id
163-
},
164160
labelsSorted() {
165161
return [...this.card.labels].sort((a, b) => (a.title < b.title) ? -1 : 1)
166162
},
@@ -199,10 +195,21 @@ export default {
199195
},
200196
},
201197
watch: {
202-
currentCard(newValue) {
203-
if (newValue) {
204-
this.$nextTick(() => this.$el.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'center' }))
205-
}
198+
'$route.params.cardId': {
199+
immediate: true,
200+
handler(cardId) {
201+
if (!this.card) {
202+
return
203+
}
204+
const newValue = cardId && parseInt(cardId, 10) === this.card.id
205+
if (newValue === this.isCurrentCard) {
206+
return
207+
}
208+
this.isCurrentCard = newValue
209+
if (newValue) {
210+
this.$nextTick(() => this.$el.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'center' }))
211+
}
212+
},
206213
},
207214
},
208215
methods: {

0 commit comments

Comments
 (0)