Skip to content

Commit c5228a2

Browse files
committed
refactor: make select all th cell clickabel (refs SFKUI-76050)
1 parent f5babb5 commit c5228a2

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

packages/vue-labs/src/components/FTable/ITableHeaderSelectable.vue

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<script setup lang="ts">
22
import { computed, useTemplateRef } from "vue";
3+
import { assertRef } from "@fkui/logic";
34
import { useTranslate } from "@fkui/vue";
5+
import { activateCell } from "./FTable.logic";
46
import { type FTableCellApi } from "./f-table-api";
57
68
const { selectable, state } = defineProps<{ selectable: "single" | "multi"; state: boolean | "indeterminate" }>();
@@ -20,16 +22,25 @@ const ariaLabel = computed(() => {
2022
? $t("fkui.ftable.select-all.aria-label", "Välj alla rader")
2123
: $t("fkui.ftable.unselect-all.aria-label", "Avmarkera alla rader");
2224
});
25+
const inputRef = useTemplateRef("input");
2326
if (selectable === "multi") {
24-
const inputRef = useTemplateRef("input");
2527
expose.tabstopEl = inputRef;
2628
}
2729
30+
function onClick(e: Event): void {
31+
if (selectable !== "multi") {
32+
return;
33+
}
34+
e.stopPropagation();
35+
assertRef(inputRef);
36+
activateCell(inputRef.value, { focus: true });
37+
emit("toggle");
38+
}
2839
defineExpose(expose);
2940
</script>
3041

3142
<template>
32-
<th scope="col" class="table-ng__column table-ng__column--selectable">
43+
<th scope="col" class="table-ng__column table-ng__column--selectable" @click="onClick">
3344
<input
3445
v-if="selectable === 'multi'"
3546
ref="input"
@@ -38,7 +49,7 @@ defineExpose(expose);
3849
type="checkbox"
3950
:aria-label
4051
tabindex="-1"
41-
@change="emit('toggle')"
52+
@click="onClick"
4253
/>
4354
</th>
4455
</template>

0 commit comments

Comments
 (0)