-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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: paste and Ctrl+z #4131
fix: paste and Ctrl+z #4131
Conversation
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.
@parasharrajat Tested based on instruction in here #3790.
I assume that copy pasting bold text from a message in E.cash is different problem, right?
Yes @mountiny That is a different issue. |
try { | ||
document.execCommand('insertText', false, markdownText); | ||
this.updateNumberOfLines(); | ||
// eslint-disable-next-line no-empty | ||
} catch (e) {} |
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.
The execCommand
API is deprecated. Is there an alternative to this?
Also, could you add a comment to explain why do we need an empty catch {}
block here?
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.
@HorusGoul Its deprecated but I didn't find any direct alternative. If we don't use it then we have to implement our own framework to manage undo redo and other operations. There are few WYSIWYG editors out there which does this but we are not currently using it.
After a careful inspection I come to the decision of using it, previously I was doing the manual paste but it lacked Undo functionality..
This is still supported for almost all browsers https://caniuse.com/?search=execCommand.
Also, I checked RN-WEB to see how they manage Copy to clipboard. They are also using it https://github.com/necolas/react-native-web/blob/98dcefd9041c10cc95a2385202498b274d926a6b/packages/react-native-web/src/exports/Clipboard/index.js#L50
I just borrowed the catch block from RN-web.
We can think about of changing to different alternative when we redesign our composer but I would say ATM its the best bet.
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.
Great! Let's merge then :)
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
fix: paste and Ctrl+z (cherry picked from commit f9d0058)
🚀 Deployed to staging in version: 1.0.79-2🚀
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
This is working as intended in MacOS Desktop and Web only. Windows is still facing this same issue #4066 |
🚀 Deployed to production in version: 1.0.79-4🚀
|
🚀 Deployed to staging in version: 1.0.79-5🚀
|
🚀 Deployed to production in version: 1.0.80-2🚀
|
@@ -353,7 +335,7 @@ class TextInputFocusable extends React.Component { | |||
onChange={() => { | |||
this.updateNumberOfLines(); | |||
}} | |||
onSelectionChange={this.saveSelection} | |||
onSelectionChange={this.onSelectionChange} |
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.
Shouldn't this be this.props.onSelectionChange
? Because onSelectionChange
does not exist as a method on Composer
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.
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.
This component is deprecated.
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.
Actually while investigating Composer
, I noticed that it has no this.onSelectionChange
method, but it is being used in the component:
App/src/components/Composer/index.js
Lines 358 to 360 in 7b8f085
onChange={this.shouldCallUpdateNumberOfLines} | |
onSelectionChange={this.onSelectionChange} | |
numberOfLines={this.state.numberOfLines} |
And found this PR, while checking out the git blame for it.
Could you please confirm that
this.onSelectionChange
should be changed to this.props.onSelectionChange
in Composer/index.js
?
Details
Fixed Issues
$ Fixes #4120
Tests | QA Steps
Tested On
Screenshots
Web
paste.mp4
Mobile Web
Desktop
iOS
Android