morphdom icon indicating copy to clipboard operation
morphdom copied to clipboard

Text selection loss during incremental AI updates

Open examan opened this issue 1 year ago • 0 comments

Currently, morphdom updates Text nodes by directly replacing the entire nodeValue:

if (morphedNode.nodeValue !== toNode.nodeValue) {
    morphedNode.nodeValue = toNode.nodeValue;
}

When working with AI-generated content, text typically grows incrementally as responses are generated. The current direct replacement approach causes any existing text selection to be lost, disrupting user interaction with the content.

examan avatar Oct 25 '24 06:10 examan