Skip to content

Commit 0e8ab04

Browse files
committed
fix styling support for tables
1 parent a5a5db7 commit 0e8ab04

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

frontend/code/components/table.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,12 @@ export class TableComponent extends ComponentBase {
330330
}
331331

332332
// Find the targeted area
333-
let styleLeft = style.left + 1;
333+
let headersOffset = this.state.headers === null ? 0 : 1;
334+
let rowNumbersOffset = this.state.show_row_numbers ? 1 : 0;
335+
336+
let styleLeft = style.left + rowNumbersOffset;
334337
let styleWidth = style.width;
335-
let styleTop = style.top === "header" ? 0 : style.top + 1;
338+
let styleTop = style.top === "header" ? 0 : style.top + headersOffset;
336339
let styleHeight = style.height;
337340

338341
// Apply the CSS to all selected cells

rio/components/table.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
@t.final
2828
@dataclass
2929
class TableSelection:
30+
_table: Table
31+
3032
_left: int
3133
_top: int | t.Literal["header"]
3234
_width: int
@@ -38,10 +40,14 @@ def style(
3840
self,
3941
*,
4042
font_weight: t.Literal["normal", "bold"] | None = None,
41-
) -> None:
43+
) -> Table:
44+
# Store the passed in values
4245
if font_weight is not None:
4346
self._font_weight = font_weight
4447

48+
# Return the table to allow chaining
49+
return self._table
50+
4551
def _as_json(self) -> JsonDoc:
4652
# Some values are always present
4753
result: JsonDoc = {
@@ -543,6 +549,7 @@ def __getitem__(
543549

544550
# Construct the result
545551
result = TableSelection(
552+
_table=self,
546553
_left=left,
547554
_top=top,
548555
_width=width,

0 commit comments

Comments
 (0)