table check touch area

This commit is contained in:
tglide committed 2023-08-16 14:02:35 +01:00
1 parent b496a54e6b
commit 1f402848db
4 files changed
+33 -16

No files matched your search

+1 -1
View File
@@ -10,7 +10,7 @@
export let required = false;
export let disabled = false;
let element: HTMLInputElement;
export let element: HTMLInputElement;
let error: string;
const handleInvalid = (event: Event) => {
+6
View File
@@ -14,3 +14,9 @@
role="cell">
<slot />
</div>
<style lang="scss">
.table-col {
position: relative;
}
</style>
+25 -14
View File
@@ -6,24 +6,35 @@
export let id: string;
export let selectedIds: string[] = [];
let el: HTMLInputElement;
const handleClick = (e: Event) => {
// Prevent the link from being followed
e.preventDefault();
if (!isHTMLInputElement(el)) return;
selectedIds = toggle(selectedIds, id);
// Hack to make sure the checkbox is checked, independent of the
// preventDefault() call above
window.setTimeout(() => {
el.checked = selectedIds.includes(id);
});
};
</script>
<TableCell>
<div class="touch-area" on:click={handleClick} on:keypress={handleClick} />
<InputCheckbox
bind:element={el}
id="select-{id}"
value={selectedIds.includes(id)}
on:click={(e) => {
// Prevent the link from being followed
e.preventDefault();
const el = e.currentTarget;
if (!isHTMLInputElement(el)) return;
selectedIds = toggle(selectedIds, id);
// Hack to make sure the checkbox is checked, independent of the
// preventDefault() call above
window.setTimeout(() => {
el.checked = selectedIds.includes(id);
});
}} />
on:click={handleClick} />
</TableCell>
<style lang="scss">
.touch-area {
position: absolute;
inset: 0;
}
</style>
@@ -235,7 +235,7 @@
<div class="u-flex u-cross-center u-gap-8">
<span class="indicator body-text-2 u-bold">{selectedDb.length}</span>
<span>
{selected.length > 1 ? 'documents' : 'document'} selected
{selectedDb.length > 1 ? 'documents' : 'document'} selected
</span>
</div>