fragmentSelection option does not allow to copy all selected text

Tags: #<Tag:0x00007efc6d5c08d0> #<Tag:0x00007efc6d5c0650>

Hello. I have such problem when I have fragmentSelection enabled with selectionMode: ‘single’ I cannot copy all partially selected text. Only currently active cell data is copied in the result.
https://jsfiddle.net/n0b36j5s/

Also, I noticed that when I do not enable the CopyPaste plugin then it allows me to copy partially selected data through the multiple cells with fragmentSelection: true, selectionMode: ‘single’.
But it seems that in my jsfiddle example, the CopyPaste plugin is enabled by default and I do not know how to exclude it.

Anyway, when I use fragmentSelection without the CopyPaste plugin then I have no possibility to copy selected active cell data.

Is there any solution to use both features together: copy partially selected text (fragmentSelection: true) and copy only active cell data when no partial text is selected (CopyPaste plugin)?

Thank you.

Thank you for sharing the issue report, @Maximilian

In an older version of Handsontable, v8, we removed the selection on the mouseup event, and now we don’t. It seems that before, the UX was clearer, as we were only visually highlighting the content—now, it looks like an actual selection that stays after we release the mouse button.

How to deal with that? If you turn off the selection plugin by adding copyPaste: false you’ll be able to use the browser copy mechanism. You can test that by copying the area here https://jsfiddle.net/qgpnjwyf/1/ and pasting it to the console. When copyPaste is enabled (and it is by default) it copies only that one cell.

When it comes to the paste it also uses area selection, so to keep selectionMode: 'single', you’d need to call the paste from the clipboard on the getSlectedLast() cell coords or save the copied data and pass it via setDataAtCell() call.

Do I understand you correctly, that there is no sense using fragmentSelection enabled together with CopyPaste plugin enabled? Because fragmentSelection will not work as intended in this case.

It’s more like using selectionMode: 'single' with copy/pasting more than one cell as selection and copyPaste are logically connected.

So fragmentSelection doesn’t work when the CopyPaste plugin is enabled? It’s really not obvious from the documentation if it’s working in such a way as by design.
It was really more convenient when the user could copy selected cell data or use fragment selection at the same time. But currently it allows only one of these options to use.

UPD: I use handsontable in Angular project, and as I understood all plugins should be enabled separately (Because copy/paste doesn’t work without registerPlugin call). So I do registerPlugin(CopyPaste);. Then I add fragmentSelection: true, copyPaste: true to GridSettings while creating Handsontable instance. And I cannot use fragment selection even within one cell. It copies all cell data on Ctrl + C when I have only partly selected text inside cell.
In your above example it looks like this case works correctly, but not in my case with Angular.
Can you help with this case?

That is true. I made a note to fill the documentation with the needed details.

When it comes to the setup there are two ways:

  1. When you do not need to have Handsontable’s copyPaste - just the browser one > skip the CopyPaste plugin as it is not included in the base module.
  2. If you would like to have the Handsontable’s CopyPaste ability as you turn on/off the fragmentSelection > register the CopyPaste plugin and once you turn the fragmentSelection on turn the CopyPaste off via updateSettings()

So to sum up:
{singleSelection: true, copyPaste: true, fragmentSelection: true} - will allow to copy only the selected cell data. Also, it will allow the selection of text through the cells with fragmentSelection, but will not allow copying this text. Which makes using fragmentSelection useless when combined with copyPaste. It will only confuse the user with the ability to select all the text, but not allow it to copy.

Yes, the set of those options is not complementary or compatible with their purpose, like using editor: true with readOnly: false or allowInsertColumn with an object dataset. With such a list of options that we have, there might be some that simply do not match. The issue here is that since v10.0.0, the highlight of those cells has remained, so it creates the idea that the data can actually be copied. I’ll do my best to track the change down and investigate it further.