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

Enhancement to issue #28859 #29231

Closed
wants to merge 1 commit into from
Closed

Enhancement to issue #28859 #29231

wants to merge 1 commit into from

Conversation

Quintis1212
Copy link
Contributor

@Quintis1212 Quintis1212 commented Feb 22, 2021

Hello everyone ) this is enhancement for #28859 issue. I made a focus settings specific to an image and reset to a neutral position when a new image is uploaded

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Feb 22, 2021
@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @Quintis1212! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@Quintis1212 Quintis1212 changed the title fix to issue #28859 Enhancement to issue #28859 Feb 22, 2021
@stokesman
Copy link
Contributor

stokesman commented Feb 23, 2021

Hi @Quintis1212, thanks for your work on this.

I was surprised by the approach here as I would have thought to handle this within the Cover block and not in the focal point picker component. But then it seems you've intended to make an extra enhancement beyond what (I interpret) is needed to resolve the issue. I can see how the title of the issue might suggest it though.

As I interpret it, the needed solution is to reset the focal point when changing the media. This PR does that. The extra enhancement would be to restore a previously set focal point for a previously used image. Though, that part didn't work for me when I tested this.

I think it'd be best to narrow the focus of this PR to just make the reset and for that, I don't think the focal point picker component should be changed. That's because there should be a solution with fewer changes. At present, the single place this enhancement is needed is the Cover block. The only other use of the focal point picker is in the Media & Text block and that block already resets the focal point when the media changes. The same behavior in the Cover block could be had by adding a single line. Note that the Cover block already resets the focal point when changing the media if the type of media is a video:

setAttributes( {
url: media.url,
id: media.id,
backgroundType: mediaType,
...( mediaType === VIDEO_BACKGROUND_TYPE
? { focalPoint: undefined, hasParallax: undefined }
: {} ),
} );

That's my take and hopefully, it makes sense to you as well.

@stokesman stokesman added [Type] Enhancement A suggestion for improvement. and removed First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository labels Feb 23, 2021
@Quintis1212
Copy link
Contributor Author

Hi @Quintis1212, thanks for your work on this.

I was surprised by the approach here as I would have thought to handle this within the Cover block and not in the focal point picker component. But then it seems you've intended to make an extra enhancement beyond what (I interpret) is needed to resolve the issue. I can see how the title of the issue might suggest it though.

As I interpret it, the needed solution is to reset the focal point when changing the media. This PR does that. The extra enhancement would be to restore a previously set focal point for a previously used image. Though, that part didn't work for me when I tested this.

I think it'd be best to narrow the focus of this PR to just make the reset and for that, I don't think the focal point picker component should be changed. That's because there should be a solution with fewer changes. At present, the single place this enhancement is needed is the Cover block. The only other use of the focal point picker is in the Media & Text block and that block already resets the focal point when the media changes. The same behavior in the Cover block could be had by adding a single line. Note that the Cover block already resets the focal point when changing the media if the type of media is a video:

setAttributes( {
url: media.url,
id: media.id,
backgroundType: mediaType,
...( mediaType === VIDEO_BACKGROUND_TYPE
? { focalPoint: undefined, hasParallax: undefined }
: {} ),
} );

That's my take and hopefully, it makes sense to you as well.

Hi @stokesman , i add new code to shared.js in cover block as you advised:
`
setAttributes( {
url: media.url,
id: media.id,
backgroundType: mediaType,
...( mediaType === VIDEO_BACKGROUND_TYPE
? { focalPoint: undefined, hasParallax: undefined }
: {} ),
...( mediaType === IMAGE_BACKGROUND_TYPE
? { focalPoint: undefined, hasParallax: undefined }
: {} ),
} );

`

But its work with errors :
Снимок экрана от 2021-02-26 18-58-25

@stokesman
Copy link
Contributor

@Quintis1212, That error is odd. I just tested that change on both master and then even this branch and couldn't reproduce the console error 😕 . Besides that, this would be the more appropriate change:

		setAttributes( {
			url: media.url,
			id: media.id,
			backgroundType: mediaType,
			focalPoint: undefined,
			...( mediaType === VIDEO_BACKGROUND_TYPE
				? { hasParallax: undefined }
				: {} ),
		} );

It makes the reset of focalPoint unconditional (since both media types should reset that).

Maybe restarting the npm run dev could clear up the issue. That or there's something else going on in your branch and perhaps a rebase on master could help.

Base automatically changed from master to trunk March 1, 2021 15:46
@annezazu
Copy link
Contributor

annezazu commented Jul 28, 2022

@Quintis1212 is work continuing here on your PR? For now, going to mark as stale :) Let me know if there's any support that can be provided to help you merge any of your open PRs.

@annezazu annezazu added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Jul 28, 2022
@Quintis1212
Copy link
Contributor Author

@annezazu Hi . I am closing this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants