Fabric.js: Updating the text while editing only works once

Created on 13 Feb 2019  路  5Comments  路  Source: fabricjs/fabric.js

Version

2.4.0

Test Case

http://jsfiddle.net/kjqsef53/3/

Information about environment

Seems to me that it doesn't matter..

Steps to reproduce

Create a textbox and change the text of the textbox within it's on changed event - for example trimming the last character of the text.

Expected Behavior

Adding single characters in the middle of the text would trim the last character for every added character.

Actual Behavior

Only the text change in the first event is correct, for every other text update the text isn't trimmed..

fix-next needs_confirmation

Most helpful comment

Sorry for never getting back.
I do not think you can easily change the text while typing.
I did not inspect the fiddle yet, i ll label this issue so that i can look at it tomorrow

All 5 comments

I don't see any error here, your code just removes the last character of the textbox - which is always C in your case. What do you want to achieve?

That's the problem.. Why is it always C? and not B in the second function call and then A in the third etc... The code should be equal to what the insert key does in windows.

Sorry for never getting back.
I do not think you can easily change the text while typing.
I did not inspect the fiddle yet, i ll label this issue so that i can look at it tomorrow

This is my current workaround

/**
 * This function seems to have no drawbacks but can be removed if issue is resolved
 * Issue is found here: <link to this issue>
 */
private reEnterEditingToCircumventFabricBug(cursorPosition: number) {
    this.textbox!.exitEditing();
    this.textbox!.enterEditing();
    this.textbox!.setSelectionStart(cursorPosition);
}

Just to give you an id茅 of how to solve it properly 馃檹

my time for fabric is really thin since april!
I'm sorry i have barely time to answer questions here.

Hope i can get back to normal support and featuer build.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eugene-g13 picture eugene-g13  路  3Comments

Vivek-KT picture Vivek-KT  路  3Comments

eddieyangtx picture eddieyangtx  路  5Comments

bevacqua picture bevacqua  路  4Comments

semiadam picture semiadam  路  3Comments