|
172 | 172 | }[][] = [[]];
|
173 | 173 |
|
174 | 174 | $: if (!dequal(values, old_val)) {
|
| 175 | + if (parent) { |
| 176 | + for (let i = 0; i < 50; i++) { |
| 177 | + parent.style.removeProperty(`--cell-width-${i}`); |
| 178 | + } |
| 179 | + } |
175 | 180 | // only reset sort state when values are changed
|
176 | 181 | const is_reset =
|
177 | 182 | values.length === 0 || (values.length === 1 && values[0].length === 0);
|
|
198 | 203 | if ($df_state.current_search_query) {
|
199 | 204 | df_actions.handle_search(null);
|
200 | 205 | }
|
| 206 | +
|
| 207 | + if (parent && cells.length > 0) { |
| 208 | + set_cell_widths(); |
| 209 | + } |
201 | 210 | }
|
202 | 211 |
|
203 | 212 | $: if ($df_state.current_search_query !== undefined) {
|
|
365 | 374 | if (show_row_numbers) {
|
366 | 375 | parent.style.setProperty(`--cell-width-row-number`, `${widths[0]}px`);
|
367 | 376 | }
|
| 377 | +
|
| 378 | + for (let i = 0; i < 50; i++) { |
| 379 | + if (!column_widths[i]) { |
| 380 | + parent.style.removeProperty(`--cell-width-${i}`); |
| 381 | + } else if (column_widths[i].endsWith("%")) { |
| 382 | + const percentage = parseFloat(column_widths[i]); |
| 383 | + const pixel_width = Math.floor((percentage / 100) * parent.clientWidth); |
| 384 | + parent.style.setProperty(`--cell-width-${i}`, `${pixel_width}px`); |
| 385 | + } else { |
| 386 | + parent.style.setProperty(`--cell-width-${i}`, column_widths[i]); |
| 387 | + } |
| 388 | + } |
| 389 | +
|
368 | 390 | widths.forEach((width, i) => {
|
369 | 391 | if (!column_widths[i]) {
|
370 |
| - parent.style.setProperty( |
371 |
| - `--cell-width-${i}`, |
372 |
| - `${width - scrollbar_width / widths.length}px` |
373 |
| - ); |
| 392 | + const calculated_width = `${Math.max(width, 45)}px`; |
| 393 | + parent.style.setProperty(`--cell-width-${i}`, calculated_width); |
374 | 394 | }
|
375 | 395 | });
|
376 | 396 | }
|
377 | 397 |
|
378 | 398 | function get_cell_width(index: number): string {
|
379 |
| - return column_widths[index] |
380 |
| - ? `${column_widths[index]}` |
381 |
| - : `var(--cell-width-${index})`; |
| 399 | + return `var(--cell-width-${index})`; |
382 | 400 | }
|
383 | 401 |
|
384 | 402 | let table_height: number =
|
|
725 | 743 | role="grid"
|
726 | 744 | tabindex="0"
|
727 | 745 | >
|
728 |
| - <table bind:this={table} class:fixed-layout={column_widths.length != 0}> |
| 746 | + <table bind:this={table}> |
729 | 747 | {#if label && label.length !== 0}
|
730 | 748 | <caption class="sr-only">{label}</caption>
|
731 | 749 | {/if}
|
|
1021 | 1039 | border-collapse: separate;
|
1022 | 1040 | }
|
1023 | 1041 |
|
1024 |
| - table.fixed-layout { |
1025 |
| - table-layout: fixed; |
1026 |
| - } |
1027 |
| -
|
1028 | 1042 | thead {
|
1029 | 1043 | position: sticky;
|
1030 | 1044 | top: 0;
|
|
0 commit comments