-
Notifications
You must be signed in to change notification settings - Fork 629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix pasting copied text inside TextAreaWidget #625
Conversation
js/src/lib/components/InferenceWidget/shared/WidgetTextarea/WidgetTextarea.svelte
Outdated
Show resolved
Hide resolved
2c77542
to
ff30cc5
Compare
js/src/lib/components/InferenceWidget/shared/WidgetTextarea/WidgetTextarea.svelte
Outdated
Show resolved
Hide resolved
}); | ||
spanEl.blur(); | ||
} | ||
function handlePaste(e: ClipboardEvent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still buggy: if you copy some text into the area, click outside of it, and select an example, the content is not changed.
Also if you paste with the text content selected, the text is appended at the beginning of the content instead of replacing it.
I feel this way of doing things is basically breaking the way Svelte handle input / state.
If you're using a span only because textarea don't adjust its height with content (why do we want this anyway ?), I strongly suggest you use a textarea and add some simple code to handle resizing according to its content, it's very easy (I've done it multiple times in the past using React).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(we tried implementing contentEditable element in a React project I work on, and we entered a world of pain doing so - like is seemingly the case here :D )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9b34fec wdyt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mishig25 looks like it's working much better !
thanks for taking the time to address this
This PR fixes a bug where copied text was being pasted with a style inside the span text area (which is the default span behaviour)
Test it here on netlify