Tracing system breaks the copy/paste functionality

Posted by: davide.vago on 3 December 2020, 10:39 pm EST

  • Posted 3 December 2020, 10:39 pm EST

    Hi there,

    I'm reaching you out as it seems there is a problem on the copy/paste function when the tracing system is on.

    Case:
    - Add a new line within the sheet
    - Select a cell containing a formula (which automatically displays the traces)
    - Copy and paste the cell into the new line
    - Observe the formula bar at the top

    Expected behaviour:
    The content of the cells should be based on the formula and automatically show the traces as per the pre-existing cells.

    Current behaviour:
    The content of the cells is a mere text so the formula gets lost.


    Please check out this sandbox based on the last one from Avinash (your support team):

    https://codesandbox.io/s/spreadjs-tracing-copy-paste-loses-formula-cyr6n


    Note: our default options for the copy/paste has: GC.Spread.Sheets.ClipboardPasteOptions.all
    So it should copy over text, formula, style and tag
  • Replied 7 December 2020, 9:06 pm EST

    Hi Davide,

    We are able to observe the issue hence we have forwarded it to the concerned team for further investigation. We will update you regarding this as soon as we get any information. The internal ID for this issue will be SJS-6800.

    Regards
    Avinash
  • Replied 9 December 2020, 2:48 pm EST

    Hi Davide,

    The Dev team informed us that it is by design. Please refer to the following workaround that should achieve the same.


    var oldFn = GC.Spread.Sheets.CellTypes.Text.prototype.paint;
    GC.Spread.Sheets.CellTypes.Text.prototype.paint = function (
    ctx,
    value,
    x,
    y,
    w,
    h,
    style,
    context
    ) {
    var sheet = context.sheet,
    row = context.row,
    col = context.col,
    tag = sheet.tag();
    var cellIndicatorColor = tag && tag[row + "_" + col];
    if (cellIndicatorColor) {
    style.backColor = cellIndicatorColor;
    }
    return oldFn.apply(this, arguments);
    };


    sample: https://codesandbox.io/s/spreadjs-tracing-copy-paste-loses-formula-forked-llurc?file=/src/index.js:23-473

    Regards
    Avinash
  • Replied 9 December 2020, 8:20 pm EST

    Hi Avinash,

    This doesn't really solve the problem, by design the product is providing a broken experience.

    Injecting a "workaround" is just wrong as concept, the snippet, you gave, means I have to override the prototype of an existing Object which is bad practice.

    It would be good if the developers could provide (extend) options (in the next releases) to achieve the user expected behaviour without suggesting to override prototypes of the library.

    Regards,
    Davide

  • Replied 10 December 2020, 5:32 pm EST

    Hi Davide,

    Thanks for the information. We have shared it with our Dev team. We will update you once we have any information from the team.

    Regards
    Avinash
  • Replied 15 December 2020, 12:11 am EST

    Hi Davide,

    The Dev informed us that if you would rather not overwrite that prototype, another suggestion would be to use similar code for a custom cell type to achieve the same functionality.

    Regards
    Avinash
  • Marked as Answer

    Replied 8 April 2021, 1:04 am EST

    Hi Avinash, as per internal support board, the issue appears to be related to the clipboardPasted event and cellRange style rather than the tracing system itself.

    I would mark this thread as completed and follow up the support ticket instead.

    Thanks for your support.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels