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

Consolidate disparate "copy block" actions #23088

Conversation

ntsekouras
Copy link
Contributor

Description

Resolves #23031

Two recent PRs have added ways to more conveniently copy an entire block from the editor, one using the Ctrl-C and Ctrl-X keyboard shortcuts (#22186), one using a new "Copy" menu item in the block's advanced settings (#22214).

While these achieve the same result for the user, their implementations follow different User experience on how the user is notified about the copy action.

In this PR using the "Copy" menu item no longer results in the updating the label to "Copied", but rather results in flashing the block and displaying a snackbar notification.

How has this been tested?

Screenshots

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@ellatrix
Copy link
Member

Could we update all copy buttons to use the "snackbar"?

Copy link
Member

@ellatrix ellatrix left a comment

Choose a reason for hiding this comment

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

Looks good to me! Let's just fix the onClose and merge.

@ntsekouras ntsekouras force-pushed the fix/consolidate-disparate-copy-block-actions branch from 1a79894 to d735e8e Compare June 12, 2020 09:27
@ntsekouras ntsekouras changed the title WIP: Consolidate disparate "copy block" actions Consolidate disparate "copy block" actions Jun 12, 2020
@ntsekouras ntsekouras force-pushed the fix/consolidate-disparate-copy-block-actions branch from d735e8e to dcd525a Compare June 12, 2020 12:17
@ellatrix ellatrix merged commit 84df4bd into WordPress:master Jun 12, 2020
@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Jun 12, 2020
@github-actions
Copy link

Congratulations on your first merged pull request, @ntsekouras! 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!

@github-actions github-actions bot added this to the Gutenberg 8.4 milestone Jun 12, 2020
@ntsekouras ntsekouras deleted the fix/consolidate-disparate-copy-block-actions branch June 12, 2020 15:10
Copy link
Contributor

@mcsf mcsf left a comment

Choose a reason for hiding this comment

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

Thanks for the improvement! I left a couple of questions.

@@ -15,7 +15,7 @@ import { __, sprintf } from '@wordpress/i18n';
*/
import { getPasteEventData } from '../../utils/get-paste-event-data';

function useNotifyCopy() {
export function useNotifyCopy() {
Copy link
Contributor

Choose a reason for hiding this comment

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

With useNotifyCopy being used in more than one component, is copy-handler still the right place for its definition? (Also, is this hook a good abstraction to begin with? 🙂)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey Miguel, thanks for the feedback!

useNotifyCopy could certainly go to a different file, under copy-handler folder ( even if it wasn't reused ) and maybe renamed to reflect that handles cut notifications too.

I believe it's a good abstraction as it does one thing: notifies the user of a copy/cut action. Every such action should have consistency about the way a user is notified.

Comment on lines +105 to +108
if ( blocks.length === 1 ) {
flashBlock( selectedBlockClientIds[ 0 ] );
}
notifyCopy( 'copy', selectedBlockClientIds );
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you weighed the benefits of combining notify and flash somewhere — maybe at the action level?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course I thought about combining them, but since flashBlock is used only if one block is copied/cut, didn't seem to me so consistent with the handling of the same actions with more blocks. So I think that CopyHandler might need more thought about this consistency in the future.

With the above said, I believe I need some more experience with the project, to understand it better and feel more comfortable before starting making more design decisions. I'm observing a bit more for now :)

Great thought provoking feedback Miguel! Really appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consolidate disparate "copy block" actions
3 participants