Unplanned
Last Updated: 28 Aug 2023 07:48 by Steven
Steven
Created on: 30 May 2023 09:36
Category: Spreadsheet
Type: Feature Request
1
Copy/pasting between two Spreadsheets removes spaces from the cell content

Bug report

If you copy a cell whose text contains multiple spaces from one Spreadsheet and try to paste it in another, the multiple spaces are lost

Reproduction of the problem

  1. Open this Dojo example - https://dojo.telerik.com/ExaliBOc/6
  2. Copy the Content of B1 cell from the first Spreadsheet.
  3. Paste it in the second Spreadsheet.

Current behavior

The pasted content contains only one spaces instead of three, as in the original cell content

Expected/desired behavior

All the spaces should be preserved when pasting in another Spreadsheet.

Environment

  • Kendo UI version: 2023.1.425
  • Browser: [all]
3 comments
Steven
Posted on: 28 Aug 2023 07:48

Thanks a lot for the new investigation and the explanation on the root cause.

Also thanks for the workaround provided. I've asked the development team to evaluate it and give me the required feedback.

ADMIN
Georgi Denchev
Posted on: 28 Aug 2023 07:10

Hello, Steven,

I am going to change this to a feature request instead so that we can review it again at some point in case there is more demand about the requested behavior. What I mentioned in my previous reply is still valid.

Best Regards,
Georgi Denchev
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources
ADMIN
Georgi Denchev
Posted on: 25 Aug 2023 08:38

Hello, Steven,

After a bit of research, this seems to be a browser related limitation and there is no way for us to handle it internally.

The issue occurs at the very beginning of the copy process. It is similar to how the browser treats text values in the DOM Tree:

Although there are multiple spaces in the text, they are not available/visible in the element itself. The browser clipboard copies this version of the text/html and that is why the spaces are missing when you paste them in another Spreadsheet.

You may wonder why this problem doesn't exist when you copy and paste inside the same Spreadsheet. The reason behind this is that the Spreadsheet component has an internal clipboard. When content is copied and pasted in the same instance, the spreadsheet makes a copy of the selection itself, rather than using the html/text from the default clipboard.

This cannot be done when pasting between different spreadsheets because there is no way to connect their internal clipboards.

Workaround

Nevertheless, I've prepared a Dojo example that showcases how you can use the copy and paste events of the Spreadsheet to store the internal content of one component in a global variable and place it in another Spreadsheet.

https://dojo.telerik.com/@gdenchev/aTuYInix 

        var globalData;
        $(function() {
          $("#spreadsheet").kendoSpreadsheet({
            copy: function(e) {
              // copy the range data exactly as it is(not affected by the default browser behavior).
              globalData = e.range._sheet.selection().getState().data;
            },
            paste: function(e) {
              let currentCC = e.clipboardContent;
              let externalHtml = e.range._sheet._workbook._clipboard._externalContent.html;
              // If the html includes an element with class kendo-clipboard, the data is coming from a spreadsheet component. If not, the data is coming from some other element and we should not modify the clipboard.
              if(externalHtml.indexOf("kendo-clipboard") > -1) {
                currentCC.data = globalData;
              }
            }

You need to add the copy/paste events to every Spreadsheet that you wish to be connected.

Best Regards,
Georgi Denchev
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources