Skip to content
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

Merged
merged 7 commits into from
Feb 4, 2022
Merged

Conversation

mishig25
Copy link
Contributor

@mishig25 mishig25 commented Jan 25, 2022

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

@mishig25 mishig25 requested a review from beurkinger January 26, 2022 11:14
});
spanEl.blur();
}
function handlePaste(e: ClipboardEvent) {
Copy link
Contributor

@beurkinger beurkinger Jan 26, 2022

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).

Copy link
Contributor

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 )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9b34fec wdyt

@mishig25 mishig25 requested a review from beurkinger January 26, 2022 15:51
Copy link
Contributor

@beurkinger beurkinger left a 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

@mishig25 mishig25 merged commit df18b71 into main Feb 4, 2022
@mishig25 mishig25 deleted the fix_span_copy branch February 4, 2022 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants