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

Media Modal: Crop selection not always visible #8398

Closed
swissspidy opened this issue Jul 21, 2021 · 10 comments · Fixed by #8501
Closed

Media Modal: Crop selection not always visible #8398

swissspidy opened this issue Jul 21, 2021 · 10 comments · Fixed by #8501
Assignees
Labels
Group: Media Group: WordPress Changes related to WordPress or Gutenberg integration P1 High priority, must do soon Type: Bug Something isn't working

Comments

@swissspidy
Copy link
Collaborator

Bug Description

Originally reported here, Lucky and I were able to reproduce this issue when trying to select a poster image.

In some cases the crop selection is not visible and trying to crop in that state results in an error.

Potentially useful files for debugging:

https://github.com/WordPress/wordpress-develop/blob/2382765afa36e10bf3c74420024ad4e85763a47c/src/js/media/controllers/cropper.js#L53-L72

https://github.com/WordPress/wordpress-develop/blob/2382765afa36e10bf3c74420024ad4e85763a47c/src/js/media/views/cropper.js#L82-L83

https://github.com/WordPress/wordpress-develop/blob/2382765afa36e10bf3c74420024ad4e85763a47c/src/js/_enqueues/vendor/imgareaselect/jquery.imgareaselect.js#L42

Expected Behaviour

Cropping selection should always be visible.

Steps to Reproduce

  1. Make browser window small
  2. Click to edit/add poster image
  3. Select a large image that would need to be cropped
  4. See no cropping selection
  5. Click "Crop image" and get an error
  6. Make window bigger
  7. See cropping selection, drag it around if wanted
  8. Click "Crop image" and see how image is sucessfully cropped

Screenshots

Screen Shot 2021-07-20 at 10 01 59 AM

Screen.Recording.2021-07-20.at.17.00.46.mov

Additional Context

  • Plugin Version: 1.9.0
  • WordPress Version: 5.7
  • Operating System: macOS
  • Browser: Chrome

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance Criteria

Implementation Brief

@swissspidy swissspidy added Type: Bug Something isn't working Group: Media P1 High priority, must do soon Group: WordPress Changes related to WordPress or Gutenberg integration Pod: WP & Infra labels Jul 21, 2021
@swissspidy
Copy link
Collaborator Author

@spacedmonkey Is this something you could look into as part of this sprint? It's quite an annoying issue as it prevents creators from publishing valid stories.

@spacedmonkey
Copy link
Contributor

@swissspidy I spent a couple of hours of this with no luck on debugging on implementation.

I managed to replicate the issue in customizer with a site logo. See screenshot. This implies that this is a core issue.

Screenshot 2021-07-23 at 14 37 35

Not sure of the next steps..

@spacedmonkey
Copy link
Contributor

It seems to be known issue - https://core.trac.wordpress.org/ticket/53300

@spacedmonkey spacedmonkey added the Status: Blocked On hold for the time being label Jul 23, 2021
@swissspidy swissspidy removed the Status: Blocked On hold for the time being label Jul 23, 2021
@swissspidy
Copy link
Collaborator Author

swissspidy commented Jul 23, 2021

Good to know, thanks!

The jQuery plugin responsible for the cropping is called imgAreaSelect and it turns out it's rather old (9 years without updates!).

Probably the reason why WP uses a patched version: https://github.com/WordPress/wordpress-develop/blob/2382765afa36e10bf3c74420024ad4e85763a47c/src/js/_enqueues/vendor/imgareaselect/jquery.imgareaselect.js

After browsing through the code and the GitHub repo I quickly found an identical bug report there with a suggested bugfix:

odyniec/imgareaselect#71 (comment)

I applied the change to jquery.imgareaselect.js locally and it worked like a charm.

To fix this we could copy the WP version of the script to our plugin (OK because it's dual-licensed under MIT), patch it and then on the editor screen replace the original script with ours.

Just need to figure out where to put it, but I suppose it's easiest to create a new package for it with a new entry in the webpack config.

@spacedmonkey
Copy link
Contributor

If it is a problem with the core version of the jquery.imgareaselect.js, could we just have a patches version of that script in our plugin. Then in our editor, we could dequeue jquery.imgareaselect.js and load a new version from our plugin. Would this work?

@swissspidy
Copy link
Collaborator Author

That's what I was suggesting, yes. It should work, but should be very easy to verify.

@csossi
Copy link

csossi commented Jul 29, 2021

Testing 8501 in QA environment

-opened poster selection and reduced browser window. selected image. crop lines not appearing and nothing happening on selecting "crop image"
https://share.getcloudapp.com/nOuv6QEY

@swissspidy
Copy link
Collaborator Author

Hmm bummer 😞

@spacedmonkey Can you take another look tomorrow? Everything seems to be fine here, with the correct script being loaded etc.

@spacedmonkey
Copy link
Contributor

@swissspidy Can you give me access to QA env? I didn't see this in local env, what to debug on QA env.

@csossi
Copy link

csossi commented Aug 2, 2021

Verified in QA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Group: Media Group: WordPress Changes related to WordPress or Gutenberg integration P1 High priority, must do soon Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants