Skip to content

Commit fa86872

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 403a4ca commit fa86872

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

‎src/segmentation/components/PaintControls.vue‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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"
@@ -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
paintToolActive.value ? '' : 'Select the Paint tool to adjust the brush'

‎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)