Skip to content

Commit d6258bb

Browse files
authored
Fix teleport to wrong instance when multiple analysis views open (#2163)
1 parent d4db26f commit d6258bb

File tree

5 files changed

+24
-21
lines changed

5 files changed

+24
-21
lines changed

changes.d/2163.fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed sorting controls appearing in wrong tab when multiple analysis view tabs are open.

src/components/cylc/analysis/BoxPlot.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
<template>
1919
<Teleport
2020
v-if="sortInputTeleportTarget"
21-
:to="`#${sortInputTeleportTarget}`"
21+
:to="sortInputTeleportTarget"
2222
>
2323
<div class="d-flex flex-grow-1 col-gap-1">
2424
<v-select
@@ -102,7 +102,7 @@ export default {
102102
},
103103
/** ID of element to teleport the sorting input (or don't render if null) */
104104
sortInputTeleportTarget: {
105-
type: String,
105+
type: HTMLElement,
106106
default: null,
107107
},
108108
},

src/components/cylc/analysis/TimeSeries.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
<template>
1919
<Teleport
2020
v-if="sortInputTeleportTarget"
21-
:to="`#${sortInputTeleportTarget}`"
21+
:to="sortInputTeleportTarget"
2222
>
2323
<div class="d-flex flex-grow-1 col-gap-1">
2424
<v-autocomplete
@@ -200,7 +200,7 @@ export default {
200200
},
201201
/** Where to teleport the sorting input (or don't render if null) */
202202
sortInputTeleportTarget: {
203-
type: String,
203+
type: HTMLElement,
204204
default: null,
205205
},
206206
},

src/views/Analysis.vue

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
6464
</v-row>
6565
<div
6666
ref="toolbar"
67-
id="analysis-toolbar"
6867
class="d-flex align-center flex-wrap my-2 col-gap-2 row-gap-4"
6968
>
7069
<!-- Toolbar -->
@@ -109,8 +108,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
109108
<v-icon :icon="$options.icons.mdiRefresh" />
110109
<v-tooltip>Refresh data</v-tooltip>
111110
</v-btn>
112-
<!-- Box plot sort input teleports here -->
113111
</v-defaults-provider>
112+
<!-- Box plot sort input teleports here -->
114113
</div>
115114
<AnalysisTable
116115
v-if="chartType === 'table'"
@@ -122,23 +121,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
122121
v-else-if="chartType === 'box'"
123122
:tasks="filteredTasks"
124123
:timing-option="timingOption"
125-
:sort-input-teleport-target="toolbar?.id"
124+
:sort-input-teleport-target="toolbarRef"
126125
v-model:initial-options="boxPlotOptions"
127126
/>
128127
<TimeSeries
129128
v-else-if="chartType === 'timeSeries'"
130129
:workflowIDs="workflowIDs"
131130
:platform-option="tasksFilter.platformOption"
132131
:timing-option="timingOption"
133-
:sort-input-teleport-target="toolbar?.id"
132+
:sort-input-teleport-target="toolbarRef"
134133
v-model:initial-options="timeseriesPlotOptions"
135134
/>
136135
</v-container>
137136
</div>
138137
</template>
139138

140139
<script>
141-
import { ref } from 'vue'
140+
import { useTemplateRef } from 'vue'
142141
import {
143142
debounce,
144143
pick,
@@ -268,8 +267,7 @@ export default {
268267
*/
269268
const chartType = useInitialOptions('chartType', { props, emit }, 'table')
270269
271-
/** @type {import('vue').Ref<HTMLElement>} template ref */
272-
const toolbar = ref(null)
270+
const toolbarRef = useTemplateRef('toolbar')
273271
274272
/**
275273
* The Vuetify data table options (sortBy, page etc).
@@ -292,10 +290,10 @@ export default {
292290
return {
293291
tasksFilter,
294292
chartType,
295-
toolbar,
293+
toolbarRef,
296294
dataTableOptions,
297295
boxPlotOptions,
298-
timeseriesPlotOptions
296+
timeseriesPlotOptions,
299297
}
300298
},
301299

tests/e2e/specs/analysis.cy.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,12 @@ function addView (view) {
424424
describe('Filters and Options save state', () => {
425425
const numTasks = sortedTasks.length
426426
describe('Options save state', () => {
427-
it('remembers table and box & whiskers toggle option when switching between workflows', () => {
427+
beforeEach(() => {
428428
cy.visit('/#/workspace/one')
429429
addView('Analysis')
430+
})
431+
432+
it('remembers table and box & whiskers toggle option when switching between workflows', () => {
430433
cy.get('.c-analysis [data-cy=box-plot-toggle]')
431434
.click()
432435
.get('.vue-apexcharts')
@@ -439,13 +442,6 @@ describe('Filters and Options save state', () => {
439442
cy.get('.vue-apexcharts')
440443
.should('be.visible')
441444
})
442-
})
443-
444-
describe('State saving', () => {
445-
beforeEach(() => {
446-
cy.visit('/#/workspace/one')
447-
addView('Analysis')
448-
})
449445

450446
it('remembers task name, platform and timings when switching between workflows', () => {
451447
// Check default options
@@ -541,5 +537,13 @@ describe('Filters and Options save state', () => {
541537
.contains('Count')
542538
.should('be.visible')
543539
})
540+
541+
it('shows sorting controls in correct tab', () => {
542+
addView('Analysis') // second analysis view
543+
cy.get('.c-analysis [data-cy=box-plot-toggle]:last')
544+
.click()
545+
.get('[data-cy="box-plot-sort-select"]')
546+
.should('be.visible')
547+
})
544548
})
545549
})

0 commit comments

Comments
 (0)