Skip to content

Commit cee169f

Browse files
committed
fix(segmentation): toggle the paint switches from their labels
Allow Overlap and Sync Views labels are now labels for their switches, so clicking the text toggles the switch like any other checkbox label.
1 parent e7ae336 commit cee169f

3 files changed

Lines changed: 29 additions & 9 deletions

File tree

‎src/segmentation/components/PaintControls.vue‎

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
v-model="controlPanels"
55
multiple
66
variant="accordion"
7-
class="annotation-panels paint-process-panels"
7+
class="annotation-panels"
88
>
99
<v-expansion-panel :value="PAINT_PANEL">
1010
<v-expansion-panel-title>
1111
<v-icon class="annotation-panel-icon">mdi-brush</v-icon>
1212
Paint
1313
</v-expansion-panel-title>
14-
<v-expansion-panel-text class="control-panel-body">
14+
<v-expansion-panel-text>
1515
<v-row
1616
no-gutters
1717
align="center"
@@ -176,10 +176,14 @@
176176
</div>
177177
<div class="paint-switches mb-2">
178178
<div class="d-flex align-center">
179-
<span class="control-label text-body-2 text-no-wrap">
179+
<label
180+
:for="overlapSwitchId"
181+
class="control-label text-body-2 text-no-wrap cursor-pointer"
182+
>
180183
<v-icon size="small">mdi-set-center</v-icon>Allow Overlap
181-
</span>
184+
</label>
182185
<v-switch
186+
:id="overlapSwitchId"
183187
aria-label="Allow Overlap"
184188
v-model="allowOverlap"
185189
color="primary"
@@ -197,9 +201,15 @@
197201
class="d-flex align-center"
198202
:tabindex="brushDisabledReason ? 0 : undefined"
199203
>
200-
<span class="control-label text-body-2 text-no-wrap">
204+
<label
205+
:for="syncSwitchId"
206+
:class="[
207+
'control-label text-body-2 text-no-wrap',
208+
{ 'cursor-pointer': !brushDisabledReason },
209+
]"
210+
>
201211
<v-icon size="small">mdi-link-variant</v-icon>Sync Views
202-
</span>
212+
</label>
203213
<v-tooltip
204214
:eager="false"
205215
:disabled="!brushDisabledReason"
@@ -209,6 +219,7 @@
209219
{{ brushDisabledReason }}
210220
</v-tooltip>
211221
<v-switch
222+
:id="syncSwitchId"
212223
aria-label="Sync Views"
213224
:disabled="!!brushDisabledReason"
214225
v-model="crossPlaneSync"
@@ -227,7 +238,7 @@
227238
<v-icon class="annotation-panel-icon">mdi-cogs</v-icon>
228239
Process
229240
</v-expansion-panel-title>
230-
<v-expansion-panel-text class="control-panel-body">
241+
<v-expansion-panel-text>
231242
<ProcessControls />
232243
</v-expansion-panel-text>
233244
</v-expansion-panel>
@@ -236,7 +247,7 @@
236247
</template>
237248

238249
<script setup lang="ts">
239-
import { computed, ref, watch } from 'vue';
250+
import { computed, ref, useId, watch } from 'vue';
240251
import { storeToRefs } from 'pinia';
241252
import { PaintMode } from '@/src/core/tools/paint';
242253
import { usePaintInteractionMode } from '@/src/segmentation/composables/usePaintInteractionMode';
@@ -286,6 +297,8 @@ const {
286297
crossPlaneSync,
287298
} = storeToRefs(paintStore);
288299
const { allowOverlap } = storeToRefs(useSegmentationStore());
300+
const overlapSwitchId = useId();
301+
const syncSwitchId = useId();
289302
// Allow Overlap stays live: it also governs a polygon's Rasterize.
290303
const brushDisabledReason = computed(
291304
() =>

‎src/segmentation/components/SegmentList.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ const {
242242
<v-icon class="annotation-panel-icon">mdi-tune-variant</v-icon>
243243
Display
244244
</v-expansion-panel-title>
245-
<v-expansion-panel-text class="display-section-body">
245+
<v-expansion-panel-text>
246246
<div class="display-controls" :tabindex="viewingCine ? 0 : undefined">
247247
<div
248248
v-for="control in DISPLAY_CONTROLS"

‎tests/specs/segment-controls-accessibility.e2e.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ describe('Segment control accessibility', () => {
4949
await sync.execute((element) => element.focus());
5050
await browser.keys(' ');
5151
expect(await sync.isSelected()).toBe(!initiallySelected);
52+
53+
// Each switch toggles from its label too.
54+
await $('label*=Sync Views').click();
55+
expect(await sync.isSelected()).toBe(initiallySelected);
56+
const overlap = $('input[aria-label="Allow Overlap"]');
57+
await $('label*=Allow Overlap').click();
58+
await expect(overlap).toBeSelected();
5259
});
5360

5461
it('disables the brush controls, saying why, until the Paint tool is picked', async () => {

0 commit comments

Comments
 (0)