From edca3bcb743c7eb63e6abbaa801d3858342a8777 Mon Sep 17 00:00:00 2001 From: Lars Eberhardt <36646064+larseberhardt@users.noreply.github.com> Date: Tue, 24 Jun 2025 15:09:04 +0000 Subject: [PATCH] fix(Table): use `tr` as separator (#4083) Co-authored-by: Benjamin Canac --- src/runtime/components/Table.vue | 2 + src/theme/table.ts | 5 +- .../__snapshots__/Table-vue.spec.ts.snap | 81 ++++++++++++------- .../__snapshots__/Table.spec.ts.snap | 81 ++++++++++++------- 4 files changed, 113 insertions(+), 56 deletions(-) diff --git a/src/runtime/components/Table.vue b/src/runtime/components/Table.vue index f66a68c1..422c2b59 100644 --- a/src/runtime/components/Table.vue +++ b/src/runtime/components/Table.vue @@ -366,6 +366,8 @@ defineExpose({ + + diff --git a/src/theme/table.ts b/src/theme/table.ts index 873f4092..11985e09 100644 --- a/src/theme/table.ts +++ b/src/theme/table.ts @@ -5,11 +5,12 @@ export default (options: Required) => ({ root: 'relative overflow-auto', base: 'min-w-full overflow-clip', caption: 'sr-only', - thead: 'relative [&>tr]:after:absolute [&>tr]:after:inset-x-0 [&>tr]:after:bottom-0 [&>tr]:after:h-px [&>tr]:after:bg-(--ui-border-accented)', + thead: 'relative', tbody: 'divide-y divide-default [&>tr]:data-[selectable=true]:hover:bg-elevated/50 [&>tr]:data-[selectable=true]:focus-visible:outline-primary', tr: 'data-[selected=true]:bg-elevated/50', th: 'px-4 py-3.5 text-sm text-highlighted text-left rtl:text-right font-semibold [&:has([role=checkbox])]:pe-0', td: 'p-4 text-sm text-muted whitespace-nowrap [&:has([role=checkbox])]:pe-0', + separator: 'absolute z-[1] left-0 w-full h-px bg-(--ui-border-accented)', empty: 'py-6 text-center text-sm text-muted', loading: 'py-6 text-center' }, @@ -27,7 +28,7 @@ export default (options: Required) => ({ }, loading: { true: { - thead: 'after:absolute after:bottom-0 after:inset-x-0 after:h-px' + thead: 'after:absolute after:z-[1] after:h-px' } }, loadingAnimation: { diff --git a/test/components/__snapshots__/Table-vue.spec.ts.snap b/test/components/__snapshots__/Table-vue.spec.ts.snap index ea9e12c1..0cc2530a 100644 --- a/test/components/__snapshots__/Table-vue.spec.ts.snap +++ b/test/components/__snapshots__/Table-vue.spec.ts.snap @@ -4,13 +4,14 @@ exports[`Table > renders with as correctly 1`] = ` "
- + + @@ -57,13 +58,14 @@ exports[`Table > renders with caption correctly 1`] = ` "
Id Amount Status Email
- + + @@ -110,13 +112,14 @@ exports[`Table > renders with caption slot correctly 1`] = ` "
Table caption
Id Amount Status Email
- + + @@ -163,13 +166,14 @@ exports[`Table > renders with cell slot correctly 1`] = ` "
Caption slot
Id Amount Status Email
- + + @@ -216,13 +220,14 @@ exports[`Table > renders with class correctly 1`] = ` "
Id Amount Status Email
- + + @@ -269,7 +274,7 @@ exports[`Table > renders with columns correctly 1`] = ` "
Id Amount Status Email
- + + @@ -459,13 +465,14 @@ exports[`Table > renders with data correctly 1`] = ` "
@@ -293,6 +298,7 @@ exports[`Table > renders with columns correctly 1`] = `
- + + @@ -512,8 +519,9 @@ exports[`Table > renders with empty correctly 1`] = ` "
Id Amount Status Email
- + + @@ -528,7 +536,7 @@ exports[`Table > renders with empty slot correctly 1`] = ` "
- + + @@ -566,13 +575,14 @@ exports[`Table > renders with expanded slot correctly 1`] = ` "
@@ -552,6 +560,7 @@ exports[`Table > renders with empty slot correctly 1`] = `
- + + @@ -619,13 +629,14 @@ exports[`Table > renders with header slot correctly 1`] = ` "
Id Amount Status Email
- + + @@ -672,13 +683,14 @@ exports[`Table > renders with loading animation carousel correctly 1`] = ` "
ID Header slot Amount Status Email
- + + @@ -725,13 +737,14 @@ exports[`Table > renders with loading animation carousel-inverse correctly 1`] = "
Id Amount Status Email
- + + @@ -778,13 +791,14 @@ exports[`Table > renders with loading animation elastic correctly 1`] = ` "
Id Amount Status Email
- + + @@ -831,13 +845,14 @@ exports[`Table > renders with loading animation swing correctly 1`] = ` "
Id Amount Status Email
- + + @@ -884,13 +899,14 @@ exports[`Table > renders with loading color error correctly 1`] = ` "
Id Amount Status Email
- + + @@ -937,13 +953,14 @@ exports[`Table > renders with loading color info correctly 1`] = ` "
Id Amount Status Email
- + + @@ -990,13 +1007,14 @@ exports[`Table > renders with loading color neutral correctly 1`] = ` "
Id Amount Status Email
- + + @@ -1043,13 +1061,14 @@ exports[`Table > renders with loading color primary correctly 1`] = ` "
Id Amount Status Email
- + + @@ -1096,13 +1115,14 @@ exports[`Table > renders with loading color secondary correctly 1`] = ` "
Id Amount Status Email
- + + @@ -1149,13 +1169,14 @@ exports[`Table > renders with loading color success correctly 1`] = ` "
Id Amount Status Email
- + + @@ -1202,13 +1223,14 @@ exports[`Table > renders with loading color warning correctly 1`] = ` "
Id Amount Status Email
- + + @@ -1255,13 +1277,14 @@ exports[`Table > renders with loading correctly 1`] = ` "
Id Amount Status Email
- + + @@ -1308,7 +1331,7 @@ exports[`Table > renders with loading slot correctly 1`] = ` "
Id Amount Status Email
- + + @@ -1346,13 +1370,14 @@ exports[`Table > renders with sticky correctly 1`] = ` "
@@ -1332,6 +1355,7 @@ exports[`Table > renders with loading slot correctly 1`] = `
- + + @@ -1399,13 +1424,14 @@ exports[`Table > renders with ui correctly 1`] = ` "
Id Amount Status Email
- + + @@ -1452,8 +1478,9 @@ exports[`Table > renders without data correctly 1`] = ` "
Id Amount Status Email
- + + diff --git a/test/components/__snapshots__/Table.spec.ts.snap b/test/components/__snapshots__/Table.spec.ts.snap index cb973297..286dadc9 100644 --- a/test/components/__snapshots__/Table.spec.ts.snap +++ b/test/components/__snapshots__/Table.spec.ts.snap @@ -4,13 +4,14 @@ exports[`Table > renders with as correctly 1`] = ` "
- + + @@ -57,13 +58,14 @@ exports[`Table > renders with caption correctly 1`] = ` "
Id Amount Status Email
- + + @@ -110,13 +112,14 @@ exports[`Table > renders with caption slot correctly 1`] = ` "
Table caption
Id Amount Status Email
- + + @@ -163,13 +166,14 @@ exports[`Table > renders with cell slot correctly 1`] = ` "
Caption slot
Id Amount Status Email
- + + @@ -216,13 +220,14 @@ exports[`Table > renders with class correctly 1`] = ` "
Id Amount Status Email
- + + @@ -269,7 +274,7 @@ exports[`Table > renders with columns correctly 1`] = ` "
Id Amount Status Email
- + + @@ -459,13 +465,14 @@ exports[`Table > renders with data correctly 1`] = ` "
@@ -293,6 +298,7 @@ exports[`Table > renders with columns correctly 1`] = `
- + + @@ -512,8 +519,9 @@ exports[`Table > renders with empty correctly 1`] = ` "
Id Amount Status Email
- + + @@ -528,7 +536,7 @@ exports[`Table > renders with empty slot correctly 1`] = ` "
- + + @@ -566,13 +575,14 @@ exports[`Table > renders with expanded slot correctly 1`] = ` "
@@ -552,6 +560,7 @@ exports[`Table > renders with empty slot correctly 1`] = `
- + + @@ -619,13 +629,14 @@ exports[`Table > renders with header slot correctly 1`] = ` "
Id Amount Status Email
- + + @@ -672,13 +683,14 @@ exports[`Table > renders with loading animation carousel correctly 1`] = ` "
ID Header slot Amount Status Email
- + + @@ -725,13 +737,14 @@ exports[`Table > renders with loading animation carousel-inverse correctly 1`] = "
Id Amount Status Email
- + + @@ -778,13 +791,14 @@ exports[`Table > renders with loading animation elastic correctly 1`] = ` "
Id Amount Status Email
- + + @@ -831,13 +845,14 @@ exports[`Table > renders with loading animation swing correctly 1`] = ` "
Id Amount Status Email
- + + @@ -884,13 +899,14 @@ exports[`Table > renders with loading color error correctly 1`] = ` "
Id Amount Status Email
- + + @@ -937,13 +953,14 @@ exports[`Table > renders with loading color info correctly 1`] = ` "
Id Amount Status Email
- + + @@ -990,13 +1007,14 @@ exports[`Table > renders with loading color neutral correctly 1`] = ` "
Id Amount Status Email
- + + @@ -1043,13 +1061,14 @@ exports[`Table > renders with loading color primary correctly 1`] = ` "
Id Amount Status Email
- + + @@ -1096,13 +1115,14 @@ exports[`Table > renders with loading color secondary correctly 1`] = ` "
Id Amount Status Email
- + + @@ -1149,13 +1169,14 @@ exports[`Table > renders with loading color success correctly 1`] = ` "
Id Amount Status Email
- + + @@ -1202,13 +1223,14 @@ exports[`Table > renders with loading color warning correctly 1`] = ` "
Id Amount Status Email
- + + @@ -1255,13 +1277,14 @@ exports[`Table > renders with loading correctly 1`] = ` "
Id Amount Status Email
- + + @@ -1308,7 +1331,7 @@ exports[`Table > renders with loading slot correctly 1`] = ` "
Id Amount Status Email
- + + @@ -1346,13 +1370,14 @@ exports[`Table > renders with sticky correctly 1`] = ` "
@@ -1332,6 +1355,7 @@ exports[`Table > renders with loading slot correctly 1`] = `
- + + @@ -1399,13 +1424,14 @@ exports[`Table > renders with ui correctly 1`] = ` "
Id Amount Status Email
- + + @@ -1452,8 +1478,9 @@ exports[`Table > renders without data correctly 1`] = ` "
Id Amount Status Email
- + +