Skip to content

Commit 5773ead

Browse files
authored
fix popout columns logic for long strings (#7201)
## 📝 Summary <!-- Provide a concise summary of what this pull request is addressing. If this PR fixes any issues, list them here by number (e.g., Fixes #123). --> Issue where long strings didn't show up as popout columns, because they had markup. Also increases the width of popout columns and ensures they are truncated when inline for a clean table look. before: https://github.com/user-attachments/assets/f9a07653-9626-4ba4-99a9-2a242be5e549 after: https://github.com/user-attachments/assets/0a4e1a83-ed17-4572-8dc4-c01953aa87f9 ## 🔍 Description of Changes <!-- Detail the specific changes made in this pull request. Explain the problem addressed and how it was resolved. If applicable, provide before and after comparisons, screenshots, or any relevant details to help reviewers understand the changes easily. --> ## 📋 Checklist - [x] I have read the [contributor guidelines](https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md). - [ ] For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on [Discord](https://marimo.io/discord?ref=pr), or the community [discussions](https://github.com/marimo-team/marimo/discussions) (Please provide a link if applicable). - [ ] I have added tests for the changes made. - [x] I have run the code and verified that it works as expected. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Improves table cell rendering by detecting markdown and using a markdown renderer in popouts, refines long-string popout logic, adds copy-to-clipboard and layout tweaks, and updates tests and smoke demos. > > - **Frontend · Data Table** > - **Popout behavior**: Treat strings as inline unless content is entirely markup or short; respect wrapping; increase popout width (`w-96`); use `max-w-fit` trigger; apply wrapping styles; add copy-to-clipboard control in popout header. > - **Markdown support**: Add `isMarkdown` (via `marked`) and `MarkdownUrlDetector` to render markdown with `MarkdownRenderer` in popouts; keep `UrlDetector` for non-markdown. > - **Rendering logic**: Use `allMarkup` check; pass wrapped state consistently; minor class adjustments. > - **Tests**: Add `isMarkdown` test suite; extend `url-detector` tests. > - **Config**: Inline `streamdown` deps in Vitest server config. > - **Smoke tests**: > - Add `tables/markdown_example.py` and update `tables/rich_elements.py` (new long text with URLs, formatting). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit de7ea45. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 900c043 commit 5773ead

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

‎frontend/src/components/data-table/columns.tsx‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ const PopoutColumn = ({
332332
<EmotionCacheProvider container={null}>
333333
<Popover>
334334
<PopoverTrigger
335-
className={cn(cellStyles, "w-fit outline-hidden")}
335+
className={cn(cellStyles, "max-w-fit outline-hidden")}
336336
onClick={selectCell}
337337
onMouseDown={(e) => {
338338
// Prevent cell underneath from being selected
@@ -477,6 +477,8 @@ export function renderCellValue<TData, TValue>({
477477
const dataType = column.columnDef.meta?.dataType;
478478
const dtype = column.columnDef.meta?.dtype;
479479

480+
const isWrapped = column.getColumnWrapping?.() === "wrap";
481+
480482
if (dataType === "datetime" && typeof value === "string") {
481483
try {
482484
const date = new Date(value);
@@ -508,10 +510,13 @@ export function renderCellValue<TData, TValue>({
508510
: String(renderValue());
509511

510512
const parts = parseContent(stringValue);
511-
const hasMarkup = parts.some((part) => part.type !== "text");
512-
if (hasMarkup || stringValue.length < MAX_STRING_LENGTH) {
513+
const allMarkup = parts.every((part) => part.type !== "text");
514+
if (allMarkup || stringValue.length < MAX_STRING_LENGTH || isWrapped) {
513515
return (
514-
<div onClick={selectCell} className={cellStyles}>
516+
<div
517+
onClick={selectCell}
518+
className={cn(cellStyles, isWrapped && COLUMN_WRAPPING_STYLES)}
519+
>
515520
<UrlDetector parts={parts} />
516521
</div>
517522
);
@@ -522,9 +527,9 @@ export function renderCellValue<TData, TValue>({
522527
cellStyles={cellStyles}
523528
selectCell={selectCell}
524529
rawStringValue={stringValue}
525-
contentClassName="max-h-64 overflow-auto whitespace-pre-wrap break-words text-sm"
530+
contentClassName="max-h-64 overflow-auto whitespace-pre-wrap break-words text-sm w-96"
526531
buttonText="X"
527-
wrapped={column.getColumnWrapping?.() === "wrap"}
532+
wrapped={isWrapped}
528533
>
529534
<UrlDetector parts={parts} />
530535
</PopoutColumn>
@@ -575,7 +580,7 @@ export function renderCellValue<TData, TValue>({
575580
cellStyles={cellStyles}
576581
selectCell={selectCell}
577582
rawStringValue={rawStringValue}
578-
wrapped={column.getColumnWrapping?.() === "wrap"}
583+
wrapped={isWrapped}
579584
>
580585
<JsonOutput data={value} format="tree" className="max-h-64" />
581586
</PopoutColumn>

‎marimo/_smoke_tests/tables/rich_elements.py‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import marimo
22

3-
__generated_with = "0.15.5"
3+
__generated_with = "0.17.6"
44
app = marimo.App(width="medium")
55

66

@@ -15,7 +15,9 @@ def _():
1515

1616
@app.cell
1717
def _(mo):
18-
mo.md(r"""# Printing Rich Elements""")
18+
mo.md(r"""
19+
# Printing Rich Elements
20+
""")
1921
return
2022

2123

@@ -112,6 +114,10 @@ def simple_echo_model(messages, config):
112114
"lorem_ipsum_dollar_sit" * 20,
113115
"lorem_ipsum_dollar_sit" * 20,
114116
],
117+
"long_text_with_markup": [
118+
"lorem link: https://www.google.com" * 4,
119+
"lorem link: https://www.google.com" * 4,
120+
],
115121
"large_array": [
116122
[1] * 60,
117123
[2] * 60,
@@ -171,7 +177,9 @@ def _(data, mo, pl):
171177

172178
@app.cell
173179
def _(mo, password):
174-
mo.md(f"""### Password value: {password.value}""")
180+
mo.md(f"""
181+
### Password value: {password.value}
182+
""")
175183
return
176184

177185

0 commit comments

Comments
 (0)