Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom text editor, copy/paste issue #4222

Closed
avmalyutin opened this issue May 1, 2017 · 5 comments
Closed

Custom text editor, copy/paste issue #4222

avmalyutin opened this issue May 1, 2017 · 5 comments

Comments

@avmalyutin
Copy link

Description

I have a table with two columns: name and code. I have created a simple custom editor for code column. The idea is, when user double clicks on the cell, the custom dialog with code editor opens. I have implemented it and posted the simplified example. (Link is below).

However, I have one issue with copy/paste functionality: if I use my editor, edit some code for the cell, press “Save”, the "code" column value seems to be correctly saved. But when I select this cell and press Ctrl+C, the value is not copied.

I read the tutorial of implementing the custom editor, but seems that I have missed something there. Of there is a bug in handsontable.

Thank you in advance.

Steps to reproduce

  1. Double click on the cell of row 0 and column 1.
  2. Edit the text the appeared dialog. Press save button. Dialog dissappers
  3. Select the cell of row 0 and column 1. Press Ctrl+C
  4. Select the cell of row 1 and column 1. Press Ctrl+V
  5. Wrong value is pasted.

Demo

Link to plunker

My environment

  • Handsontable version: 0.31.2
  • Browser Name and version: Chrome 58.0.3029.81
  • Operating System: Windows 7 SP1 x64.
@AMBudnik
Copy link
Contributor

AMBudnik commented May 5, 2017

That's an interesting case. I have reproduced the issue - the content cannot be copied.

@jansiegel
Copy link
Member

@avmalyutin The edited value doesn't get copied, because Handsontable thinks that the editor is still opened, even after the user closes it. This is caused by calling

this.instance.deselectCell();

in the ScriptEditor.prototype.open method. The deselectCell method marks the editor as closed, and then the editor marks itself as opened again. After commenting this line out, it seems to work fine: http://plnkr.co/edit/ycGqH5R1SM8U2A8PHnuM?p=preview

@avmalyutin
Copy link
Author

@jansiegel Thank you for response. Unfortunately, with your solution there is one minor issue: if the

this.instance.deselectCell();

is not called and after the code editor dialog is opened I can press Enter key. However, the new line is not inserted in code editor but the next row is handsontable is selected. Then I wrapped the function invocation into setTimeout and it seems to work. I will test it a little. Here is the link to the solution:
Link to plunker

Hope somebody this will help in the future.

Thank you for help. :-)

@mrpiotr-dev
Copy link
Contributor

@avmalyutin, thanks for your plunker. I'll close this issue now.
Feel free to reopen if necessary.

@godshades
Copy link

hi I have similar problem
i'm using select2js for custom editor
I just can't copy paste any cell use custom editor
please help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants