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

focus problems #9

Open
Lokomotom opened this issue Jul 24, 2018 · 3 comments
Open

focus problems #9

Lokomotom opened this issue Jul 24, 2018 · 3 comments

Comments

@Lokomotom
Copy link

value: function focus() {
// Add an empty space to texarea. It is necessary for safari to enable "copy" command from menu bar.
this.mainElement.value = ' ';
this.mainElement.select();
}

In version 4.0.0 they updated this function and it causes this TypeError: this.mainElement.select is not a function when you focus cell which is using this editor.

Any idea how to fix it please?

@mydea
Copy link
Owner

mydea commented Jul 24, 2018

I am currently not really working on this, but I do accept PRs if you find time to figure this out!

@Lokomotom
Copy link
Author

SOLVED! Here is new solution.

ChosenEditor.prototype.createElements = function () {
this.$body = $(document.body);

      this.TEXTAREA = document.createElement('textarea');
      let select = document.createElement('select');
      this.TEXTAREA.appendChild(select);
      //this.TEXTAREA.setAttribute('type', 'text');
      this.$textarea = $(this.TEXTAREA.children[0]);

      Handsontable.dom.addClass(this.TEXTAREA.children[0], 'handsontableInput');

      this.textareaStyle = this.TEXTAREA.children[0].style;
      this.textareaStyle.width = 0;
      this.textareaStyle.height = 0;

      this.TEXTAREA_PARENT = document.createElement('DIV');
      Handsontable.dom.addClass(this.TEXTAREA_PARENT, 'handsontableInputHolder');

      this.textareaParentStyle = this.TEXTAREA_PARENT.style;
      this.textareaParentStyle.top = 0;
      this.textareaParentStyle.left = 0;
      this.textareaParentStyle.display = 'none';
      this.textareaParentStyle.width = "200px";

      this.TEXTAREA_PARENT.appendChild(this.TEXTAREA.children[0]);

      this.instance.rootElement.appendChild(this.TEXTAREA_PARENT);

      var that = this;
      this.instance._registerTimeout(setTimeout(function () {
          that.refreshDimensions();
      }, 0));
  };

@dinhgiabao1993
Copy link

@element150 Thanks a lot! You made my day. Could you please add answer to handsontable issue too? I almost miss this solution if i don't open this repo issues =(

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

No branches or pull requests

3 participants