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

Focal Point Picker: Set grid overlay state when dragging #63088

Closed
wants to merge 1 commit into from

Conversation

Mamaduka
Copy link
Member

@Mamaduka Mamaduka commented Jul 3, 2024

What?

PR updates the FocalPointPicker to set the showGridOverlay state via onDragStart and onDragEnd callbacks.

Why?

The component has clear events that trigger point updates; we can set related states during these events and avoid effect synchronization.

Testing Instructions

  1. Open a post or page.
  2. Insert a Cover block and set an image.
  3. Try updating the image focal point.
  4. The grid overlay should be displayed as before.

Testing Instructions for Keyboard

Same.

Screenshots or screencast

CleanShot.2024-07-03.at.15.54.40.mp4

@Mamaduka Mamaduka added [Type] Enhancement A suggestion for improvement. [Feature] UI Components Impacts or related to the UI component system labels Jul 3, 2024
@Mamaduka Mamaduka self-assigned this Jul 3, 2024
@Mamaduka Mamaduka requested a review from ajitbohra as a code owner July 3, 2024 12:06
Comment on lines -242 to -244
const timeout = window.setTimeout( () => {
setShowGridOverlay( false );
}, GRID_OVERLAY_TIMEOUT );
Copy link
Member Author

Choose a reason for hiding this comment

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

I've omitted this logic from the update. I'm happy to restore it, but I've not noticed a big difference.

Copy link
Contributor

@stokesman stokesman Jul 3, 2024

Choose a reason for hiding this comment

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

In general I'm a fan of avoiding effects. The difference this makes is that the grid overlay is not shown when using the inputs to change the focal point.

Possibly there’s a way to rework how the Grid visibility changes so that it show/hides without using state and avoid the effect but I'm not sure.

I don’t have much of an opinion on whether it’s okay to omit showing the grid for changes from the inputs.

Copy link

github-actions bot commented Jul 3, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: stokesman <presstoke@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka Mamaduka requested review from mirka, tyxla and stokesman and removed request for ajitbohra July 3, 2024 12:08
@Mamaduka Mamaduka added [Type] Code Quality Issues or PRs that relate to code quality and removed [Type] Enhancement A suggestion for improvement. labels Jul 3, 2024
@mirka mirka requested a review from a team July 3, 2024 21:18
@mirka mirka added the [Package] Components /packages/components label Jul 3, 2024
@ciampo
Copy link
Contributor

ciampo commented Jul 4, 2024

As @stokesman also mentioned, the grid overlay currently shows any time the value of the focal point changes — that can happen in a few ways:

  • user interactions:
    • user clicking on the canvas
    • user dragging the "dot"
    • user changing x / y values in the number inputs
  • any other external controlled updates by changing the value prop

Currently, in this PR the grid shows only when dragging the dot. Personally, I feel like we should continue to show the grid overlay on all user interactions (including clicks and number input interactions).

Also, out of curiosity — is there a particular reason why we need to rework this logic? As much as I don't like even synchronisation, the current implementation seemed to work well.

@Mamaduka
Copy link
Member Author

Mamaduka commented Jul 4, 2024

I totally missed that grid was showing on any other interaction 😅

Got idea of the idea of this refactoring after I fixed a bug in this area.

I agree that with described terms effect sync makes sense.

Thanks for the feedback 🙇

@Mamaduka Mamaduka closed this Jul 4, 2024
@Mamaduka Mamaduka deleted the update/focal-pointer-grid-overlay branch July 4, 2024 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] UI Components Impacts or related to the UI component system [Package] Components /packages/components [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants