Closed Bug 1572777 Opened 5 years ago Closed 2 years ago

Output from console.table cannot be copy-pasted nicely into a spreadsheet

Categories

(DevTools :: Console, enhancement, P3)

Desktop
All
enhancement

Tracking

(firefox111 fixed)

RESOLVED FIXED
111 Branch
Tracking Status
firefox111 --- fixed

People

(Reporter: cers, Assigned: nchevobbe)

Details

Attachments

(2 files, 1 obsolete file)

The output of console.table, while tabular, doesn't behave well when copy-pasted into a spreadsheet (currently I've only tested with google sheets).

Steps to reproduce

  1. Open console
  2. Run: console.table(Array(10))
  3. Select and copy output
  4. paste into spreadsheet

What happened?

The output now is all in one column, like so:

(index)
Values
0
undefined
1
undefined
2
undefined
3
undefined
4
undefined
5
undefined
6
undefined
7
undefined
8
undefined
9
undefined

What should have happened?

Content should have been pasted into relevant cells, like:

(index) Values
0 undefined
1 undefined
2 undefined
3 undefined
4 undefined
5 undefined
6 undefined
7 undefined
8 undefined
9 undefined
Attached patch console.table.diff (obsolete) — Splinter Review

This is a WIP patch that fixes the problem by actually outputting a table, but because having a fixed header in an actual table is wonky, it's a little less than ideal.

Maybe someone knows another way of making it copy-pastable into a spreadsheet?

All my other attempts (like using display: table/table-row/table-cell) failed.

Assignee: nobody → cers

Yeah, I tried reverting back to a plain table with sticky th at some point, but that wasn't working well.
No idea how the grid gets translated into a string when copying (this has always been a very consuming thing to get right)

Priority: -- → P3

(In reply to Nicolas Chevobbe [:nchevobbe] from comment #2)

Yeah, I tried reverting back to a plain table with sticky th at some point, but that wasn't working well.

I think my patch is working pretty well, but there may be a slight difference in the borders. That might also be fixable though.

It's perhaps worth noting that Chrome doesn't have fixed headers - maybe it's not needed?

No idea how the grid gets translated into a string when copying (this has always been a very consuming thing to get right)

Maybe an alternative solution is to change the logic here https://dxr.mozilla.org/mozilla-central/source/dom/base/nsPlainTextSerializer.cpp#605 such that it's not just based on the tag name, but also/instead the display style? Maybe something with display: table-cell; should work the same as a td/th element?

The bug assignee didn't login in Bugzilla in the last 7 months.
:nchevobbe, could you have a look please?
For more information, please visit auto_nag documentation.

Assignee: cers → nobody
Flags: needinfo?(nchevobbe)
Flags: needinfo?(nchevobbe)
Attached patch 1572777.diffSplinter Review

Updated version of the patch. It seems to work better now than before though.

Do I need to get a designer to look it over, or what is the path forward here?

Assignee: nobody → cers
Attachment #9084350 - Attachment is obsolete: true
Flags: needinfo?(nchevobbe)

The bug assignee is inactive on Bugzilla, so the assignee is being reset.

Assignee: cers → nobody
Severity: normal → S3

This has been requested also here: https://connect.mozilla.org/t5/ideas/make-console-table-results-paste-friendly-simply-by-adding-tab/idc-p/22023

Christian, this would be very nice enhancement. Any chance to finish the patch? Anything blocking it?

Flags: needinfo?(cers)

Redirect a needinfo that is pending on an inactive user to the triage owner.
:nchevobbe, since the bug has recent activity, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(cers) → needinfo?(nchevobbe)

Nicolas, should we mark this as good-first-bug?
Or rather do it ourselves?

yes, the patch attached only need a few adjustments, I'll update it and land it

Flags: needinfo?(nchevobbe)
Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/58eb265f2750 Make output of console.table() use an actual table, so it can be pasted into a spreadsheet r=jdescottes
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 111 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: