i found here on stackoverflow a post how to add a maxlength to an iText-Element in Fabric.js. This was the solution:
text.on('editing:entered', () => {
text.hiddenTextarea.setAttribute('maxlength', 20);
});
This code worked for me. But today this code doesn't work anymore. I don't have an idea why it is so. I haven't changed something at this function.
This is my Code to add the iText to the canvas:
function addiText(){
let newText = new fabric.IText('Testname', { left: 150, top: 150, fontSize: 24, fill: "#0c0c0e", fontFamily: "Arial" });
newText.on('editing:entered', () => {
newText.hiddenTextarea.setAttribute('maxlength', 10);
});
canvas.add(newText);
canvas.setActiveObject(newText);
let activeObject = canvas.getActiveObject();
setProperties(activeObject);
return activeObject;
}
Can anyone say me, why this doesn't work anymore?