Text element clone does not get cleared
nikhilmandlik opened this issue · 4 comments
Describe the bug
openmct is using "painterro": "^1.2.56" (Related bug in openmct: nasa/openmct#4019)
when a text filed is added it adds input element to document.body
Painterro version
"painterro": "^1.2.56",
but looks like latest version also has same issue.
To Reproduce
Steps to reproduce the behavior:
- run Painterro locally using
npm run dev
- go to
localhost:3000
- select text (T)
- click on canvas and add some text to it
- click 'checkmark/apply'
- inspect dom elements and find 'ptro-text-tool-input' (
document.querySelectorAll('.ptro-text-tool-input')
) - there are two elements instead of one
Expected behavior
added clone should cleanup.
Browser
Google Chrome, MAC
Brave, MAC
there is issue with clone not removed from DOM,
Line 209 in fd402ff
following apply()
fixes this issue,
apply() {
const origBorder = this.input.style.border;
const scale = this.main.getScale();
this.input.style.border = 'none';
const inputClone = this.hiddenInputClone();
html2canvas(inputClone, {
backgroundColor: null,
logging: false,
scale,
scrollX: 0,
scrollY: 0,
}).then((can) => {
this.ctx.drawImage(can, this.scaledCord[0], this.scaledCord[1]);
this.input.style.border = origBorder;
this.close();
this.main.worklog.captureState();
this.main.closeActiveTool();
inputClone.remove();
}).catch(e => {
console.error(e);
inputClone.remove();
});
}
Thanks a lot @nikhilmandlik , we will apply a fix
@nikhilmandlik Thanks for your issue, this was fixed in the 1.2.58 version
Thank you to the Painterro team for the super quick turnaround on this! We appreciate it.