Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ktable): resized column choppiness #2139

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sandbox/pages/SandboxTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
:fetcher="fetcher"
:has-error="tableErrorState"
:headers="[
{ key: 'name', label: 'Name' },
{ key: 'name', label: 'Full Name' },
{ key: 'username', label: 'Username' },
{ key: 'email', label: 'Email' },
{ key: 'email', label: 'Email', hidable: true },
{ key: 'actions', hideLabel: true }
]"
:initial-fetcher-params="{
Expand Down
53 changes: 34 additions & 19 deletions src/components/KTable/KTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,19 @@
@mouseleave="currentHoveredColumn = ''"
@mouseover="currentHoveredColumn = column.key"
>
<div class="k-table-headers-container">
<div
v-if="resizeColumns && index !== 0"
class="resize-handle previous"
@click.stop
@mousedown="startResize($event, visibleHeaders[index - 1].key)"
@mouseleave="resizerHoveredColumn = ''"
@mouseover="resizerHoveredColumn = visibleHeaders[index - 1].key"
/>

<div
v-if="resizeColumns && index !== 0"
class="resize-handle previous"
@click.stop
@mousedown="startResize($event, visibleHeaders[index - 1].key)"
@mouseleave="resizerHoveredColumn = ''"
@mouseover="resizerHoveredColumn = visibleHeaders[index - 1].key"
/>

<div
class="k-table-headers-container"
:class="{ 'resized': resizingColumn === column.key }"
>
<slot
:column="getGeneric(column)"
:name="getColumnSlotName(column.key)"
Expand All @@ -152,16 +155,16 @@
icon="chevronDown"
:size="KUI_ICON_SIZE_20"
/>

<div
v-if="resizeColumns && index !== visibleHeaders.length - 1"
class="resize-handle"
@click.stop
@mousedown="startResize($event, column.key)"
@mouseleave="resizerHoveredColumn = ''"
@mouseover="resizerHoveredColumn = column.key"
/>
</div>

<div
v-if="resizeColumns && index !== visibleHeaders.length - 1"
class="resize-handle"
@click.stop
@mousedown="startResize($event, column.key)"
@mouseleave="resizerHoveredColumn = ''"
@mouseover="resizerHoveredColumn = column.key"
/>
</th>
</tr>
</thead>
Expand Down Expand Up @@ -1173,6 +1176,11 @@ export const defaultSorter = (key: string, previousKey: string, sortOrder: strin
</script>

<style lang="scss" scoped>
/* Component variables */

$kTableThPaddingBottom: var(--kui-space-60, $kui-space-60);

/* Component styles */

.k-table-wrapper {
overflow: auto;
Expand Down Expand Up @@ -1261,7 +1269,9 @@ export const defaultSorter = (key: string, previousKey: string, sortOrder: strin
font-size: var(--kui-font-size-30, $kui-font-size-30);
font-weight: var(--kui-font-weight-semibold, $kui-font-weight-semibold);
padding: var(--kui-space-50, $kui-space-50) var(--kui-space-60, $kui-space-60);
padding-bottom: $kTableThPaddingBottom;
text-align: left;
vertical-align: bottom;

&.resizable {
min-width: 40px;
Expand Down Expand Up @@ -1309,6 +1319,11 @@ export const defaultSorter = (key: string, previousKey: string, sortOrder: strin
.caret {
margin-left: var(--kui-space-40, $kui-space-40) !important;
}

&.resized {
bottom: $kTableThPaddingBottom;
position: absolute;
}
}
}
}
Expand Down
Loading