mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-02 19:14:42 +00:00
IE replace text selection with keypress (#3137)
Why: * After creating a textbox, selecting text, and pressing a key, the first character of the previous text would remain. * This happened because the hidden textarea would not update its selection in IE when it was in the same parent element as the canvas. This change addresses the need by: * Keeping the hidden textarea in the body element. * IE now correctly updates the text selection as the user interacts with the canvas textbox.
This commit is contained in:
parent
9e4ed9565f
commit
ebb2552357
2 changed files with 1 additions and 10 deletions
|
|
@ -93,10 +93,6 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
|
|||
this.__mousedownY = pointer.y;
|
||||
this.__isMousedown = true;
|
||||
|
||||
if (this.hiddenTextarea && this.canvas) {
|
||||
this.canvas.wrapperEl.appendChild(this.hiddenTextarea);
|
||||
}
|
||||
|
||||
if (this.selected) {
|
||||
this.setCursorByClick(options.e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,12 +9,7 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
|
|||
var style = this._calcTextareaPosition();
|
||||
this.hiddenTextarea.style.cssText = 'position: absolute; top: ' + style.top + '; left: ' + style.left + ';'
|
||||
+ ' opacity: 0; width: 0px; height: 0px; z-index: -999;';
|
||||
if (this.canvas) {
|
||||
this.canvas.lowerCanvasEl.parentNode.appendChild(this.hiddenTextarea);
|
||||
}
|
||||
else {
|
||||
fabric.document.body.appendChild(this.hiddenTextarea);
|
||||
}
|
||||
fabric.document.body.appendChild(this.hiddenTextarea);
|
||||
|
||||
fabric.util.addListener(this.hiddenTextarea, 'keydown', this.onKeyDown.bind(this));
|
||||
fabric.util.addListener(this.hiddenTextarea, 'keyup', this.onKeyUp.bind(this));
|
||||
|
|
|
|||
Loading…
Reference in a new issue