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

Annotate image not properly loaded by form draw widget #9252

Open
jkuester opened this issue Jul 10, 2024 · 1 comment
Open

Annotate image not properly loaded by form draw widget #9252

jkuester opened this issue Jul 10, 2024 · 1 comment
Labels
Enketo Affects Enketo forms Type: Bug Fix something that isn't working as intended

Comments

@jkuester
Copy link
Contributor

Describe the bug
The draw/signature form functionality added in #8308 included support for "annotating" an image. Basically you upload an image into the form and then you can draw/annotate the image and save the updated file as a report attachment.

Unfortunately, if the annotation question is on the first page of the form, when the image is initially loaded, it actually shows up in the canvas zoomed too far out (instead of being properly fitted within the canvas:

Expected Actual
image image

To Reproduce

  • Use the draw_widget form and upload an image into the "Annotate image widget" question.
  • See that the image is zoomed out.
  • Use the reload button to clear the image
  • Upload the image into the question again
  • See that it is zoomed as expected

Expected behavior
The image should be loaded into the canvas at the right size the first time it is loaded.

Additional context
After doing some debugging, it appears to be a problem with how we only display the loading indicator while initializing the form. This means that the canvas.offsetWidth property is 0 until we finish initializing the for (and its widgets). Then we hide the loading indicator and display the form.

This is a problem because when the draw widget is enabled it tries to initialize the size of the canvas based on the offsetWidth/height. This, of course, does not behave as expected since the offsetWidth is still 0. The result is that the various downstream calculations in fromObjectURL do not work properly and the result is a zoomed out image.

This problem behavior does not happen if the annotation question is not on the first page. This is because the _resizeCanvas function is re-triggered when changing to a new page. At that point the loading screen is gone and canvas.offsetWidth is valued.

I am going to see if I can cook up a fix for this as part of enketo/enketo#1323, but it might require custom handling in cht-core...

@jkuester jkuester added the Type: Bug Fix something that isn't working as intended label Jul 10, 2024
@jkuester
Copy link
Contributor Author

Also, just want to note that this is not a regression since this functionality never worked in the CHT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enketo Affects Enketo forms Type: Bug Fix something that isn't working as intended
Projects
None yet
Development

No branches or pull requests

1 participant