-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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/[#21440] Copy/cut input values copying entire block #21457
fix/[#21440] Copy/cut input values copying entire block #21457
Conversation
@@ -480,6 +494,10 @@ export function documentHasSelection() { | |||
return true; | |||
} | |||
|
|||
if ( isNumberInput( document.activeElement ) ) { |
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.
Should we add this inside isTextField or should it be a separate function? Or more precisely, do we consider a "number" input as a text field? I might think yes but curious what others think?
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.
Initially I extended isTextField
but later I asked myself the same question and to me it makes more sense to have them separated. I don't consider numbers as text per se. Also curious what others think : )
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.
Code looks good to me, I'll do some testing
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 seems to work very well :) Thanks for the fix.
Congratulations on your first merged pull request, @kirilzh! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts: https://profiles.wordpress.org/me/profile/edit/ And if you don't have a WordPress.org account, you can create one on this page: https://login.wordpress.org/register Kudos! |
This has fixed the copying part of the issue, but I'm still seeing an issue once the value is pasted back into the field. The pasted value replaces the block itself, instead of being added to the field. |
Description
In
block-editor/src/components/copy-handler/index.js
this check does not passbecause
documentHasSelection()
returns false. Going deeper we see there’s a check if a text fields has a selectionI then stumbled upon this. Hence I added a function checking only
<input type="number" />
.How has this been tested?
In both Chrome and FF on MacOS.
Types of changes
Bug fix (non-breaking change) which fixes #21440 .
Checklist: