Skip to content

Commit e467d27

Browse files
committed
🐛 Last col width string concat needs parens. Added note in README and code about tableWidth overriding last col width settings
1 parent cb4b5a5 commit e467d27

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ gamalielmendez's fork added:
1515
This fork added/fixed:
1616
- Render "" instead of "undefined" if no data
1717
- Changed `on:change` to `on:blur` per warning message
18-
- Added tableWidth prop, allow last column to have auto width
18+
- Added tableWidth prop, allow last column to have auto width (overriding width settings for last col)
1919
- Fixed input loses focus
2020
- Added debounce
2121
- Fixed dispatch

src/index.svelte

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
export let EnableCursor = false;
163163
export let CurrentSelectedRow = 0;
164164
export let Striped=false;
165-
export let tableWidth=0; // allow user to define table width
165+
export let tableWidth = 0; // allow user to define table width. Defining this will __override__ last col's width settings to the reminding width
166166
export let onCellUpdate = () => {}
167167
export let onHeaderUpdate = () => {}
168168
@@ -1009,13 +1009,14 @@
10091009
<div
10101010
class="grid-cell"
10111011
on:mousedown={event => onColumnDragStart(event, i)}
1012-
style="z-index: {getCellZIndex(__affixedColumnIndices, i)}; left: {getCellLeft(
1013-
{ i, columnWidths, __affixedColumnIndices, __scrollLeft }
1014-
)}px; height: {rowHeight}px; line-height: {rowHeight}px; width: {
1015-
i===columnWidths.length-1 ? lastColWidth+1 : columnWidths[i]+'px'
1016-
}; {allowColumnReordering ? 'cursor:pointer;' : ''}"
1017-
title={column.display || ''}
10181012
use:dragCopy={allowColumnReordering}
1013+
style="
1014+
z-index: {getCellZIndex(__affixedColumnIndices, i)};
1015+
left: {getCellLeft({ i, columnWidths, __affixedColumnIndices, __scrollLeft })}px;
1016+
height: {rowHeight}px; line-height: {rowHeight}px;
1017+
width: {(i===columnWidths.length-1 ? lastColWidth+1 : columnWidths[i])+'px'};
1018+
{allowColumnReordering ? 'cursor:pointer;' : ''}"
1019+
title={column.display || ''}
10191020
role="columnheader">
10201021
{#if column.headerComponent}
10211022
<svelte:component this={column.headerComponent} {column}

0 commit comments

Comments
 (0)