Skip to content

Commit 2072361

Browse files
datapumpernickelChartman123
authored andcommitted
fix: linting fail because of additional tab
Signed-off-by: paul bochtler <65470117+datapumpernickel@users.noreply.github.com>
1 parent 1896f01 commit 2072361

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

src/components/Questions/QuestionRanking.vue

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,16 @@
7474
role="listitem">
7575
<span class="ranking-item__position">{{ index + 1 }}.</span>
7676
<NcActions
77+
:id="`ranking-${option.id}-drag`"
78+
:container="`#ranking-${option.id}-drag`"
7779
:aria-label="t('forms', 'Move option actions')"
7880
class="ranking-item__drag-handle"
7981
variant="tertiary-no-background">
8082
<template #icon>
8183
<IconDragIndicator :size="20" />
8284
</template>
8385
<NcActionButton
86+
ref="buttonOptionUp"
8487
:disabled="index === 0"
8588
@click="onMoveUp(index)">
8689
<template #icon>
@@ -89,6 +92,7 @@
8992
{{ t('forms', 'Move option up') }}
9093
</NcActionButton>
9194
<NcActionButton
95+
ref="buttonOptionDown"
9296
:disabled="index === rankedOptions.length - 1"
9397
@click="onMoveDown(index)">
9498
<template #icon>
@@ -308,6 +312,11 @@ export default {
308312
;[items[index - 1], items[index]] = [items[index], items[index - 1]]
309313
this.rankedOptions = items
310314
this.emitValues()
315+
const newIndex = index - 1
316+
this.focusButton(
317+
newIndex > 0 ? 'buttonOptionUp' : 'buttonOptionDown',
318+
newIndex,
319+
)
311320
},
312321
313322
/**
@@ -321,6 +330,28 @@ export default {
321330
;[items[index], items[index + 1]] = [items[index + 1], items[index]]
322331
this.rankedOptions = items
323332
this.emitValues()
333+
const newIndex = index + 1
334+
this.focusButton(
335+
newIndex < this.rankedOptions.length - 1
336+
? 'buttonOptionDown'
337+
: 'buttonOptionUp',
338+
newIndex,
339+
)
340+
},
341+
342+
/**
343+
* Re-focus a button ref inside a v-for after reorder
344+
*
345+
* @param {string} refName The ref name ('buttonOptionUp' or 'buttonOptionDown')
346+
* @param {number} index The index of the item in the v-for
347+
*/
348+
focusButton(refName, index) {
349+
this.$nextTick(() => {
350+
const refs = this.$refs[refName]
351+
if (Array.isArray(refs) && refs[index]) {
352+
refs[index].$el?.focus()
353+
}
354+
})
324355
},
325356
326357
/**

src/models/AnswerTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ export default {
269269

270270
ranking: {
271271
component: markRaw(QuestionRanking),
272-
icon: markRaw(IconSwapVertical),
272+
icon: markRaw(IconSwapVertical),
273273
label: t('forms', 'Ranking'),
274274
predefined: true,
275275
validate: (question) => question.options.length > 0,

0 commit comments

Comments
 (0)