Skip to content

Move setSelect into the Jcrop init callback on the photo crop page - #9259

Open
c-tonneslan wants to merge 1 commit into
mysociety:developfrom
c-tonneslan:fix/profile-photo-setselect-undefined
Open

Move setSelect into the Jcrop init callback on the photo crop page#9259
c-tonneslan wants to merge 1 commit into
mysociety:developfrom
c-tonneslan:fix/profile-photo-setselect-undefined

Conversation

@c-tonneslan

Copy link
Copy Markdown

Closes #9196.

jcrop_api only gets assigned inside the Jcrop init callback (function(){ jcrop_api = this; ... }), but setSelect was being called the next line down, before the callback had run. Browsers were throwing Cannot read properties of undefined (reading 'setSelect') and the default crop selection wasn't drawn, so users had to know to drag and select before they could save (this is exactly what @FOIMonkey hit).

Move the setSelect call inside the callback so it runs after the api object exists.

Jcrop returns the instance via a callback, so jcrop_api is undefined
when the next statement runs. The browser throws 'Cannot read
properties of undefined (reading setSelect)' and the default crop box
never appears, which is what @FOIMonkey reported in mysociety#9196.

Moving the setSelect call inside the init callback fires it once the
api object actually exists.

Closes mysociety#9196

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JavaScript error on profile photo crop page

1 participant