TextWidgetAnnotation page move + apply change event

WebViewer Version:
8.11
Do you have an issue with a specific file(s)?
No
Can you reproduce using one of our samples or online demos?
Yes
Are you using the WebViewer server?
No
Does the issue only happen on certain browsers?
No
Is your issue related to a front-end framework?
Yes
Is your issue related to annotations?
Yes
Please give a brief summary of your issue:
When I move my TextWidgetAnnotation from a page to another, the name change
I have to do a dirty code to prevent that problem, Is there a way to do better ?

annotationManager.addEventListener('annotationChanged', (annotations, action, { imported }) => {
        if (action == 'delete' && annotations && annotations.length == 1) {
          me.fieldPageMoving = { currentAnnotation: annotations[0], currentDate: new Date() };
        }
        if (
          action == 'add' &&
          annotations &&
          annotations.length == 1 &&
          me.fieldPageMoving &&
          me.fieldPageMoving.currentDate &&
          new Date().getTime() - me.fieldPageMoving.currentDate.getTime() < 1000 * 2 &&
          me.fieldPageMoving.currentAnnotation['xi'] &&
          me.fieldPageMoving.currentAnnotation['xi']['trn-form-field-name'] &&
          annotations[0]['xi'] &&
          annotations[0]['xi']['trn-form-field-name'] &&
          annotations[0]['xi']['trn-form-field-name'].indexOf('TextFormField') != -1
        ) {
          const c_annot: Core.Annotations.Annotation = annotations[0];
          c_annot['xi']['trn-form-field-name'] = me.fieldPageMoving.currentAnnotation['xi']['trn-form-field-name'];
        }
      });

I got a second question :
Is there an eventListener for the Apply change button ?

1 Like

Hello,

Thank you for contacting WebViewer Support. For the issue with field names changing when moving to another pages, we have added this to our backlog and will fix this in a future sprint. Thank you for pointing this issue out to us. For the sample code you posted, that would be a similar approach to what I would suggest as a workaround. Only issue I see is you should be using annotations[0]. getCustomData('trn-form-field-name') and setCustomData instead of accessing it using “xi” (this is from a property getting minify, so it will change in another version).
https://docs.apryse.com/api/web/Core.Annotations.Annotation.html#setCustomData__anchor
https://docs.apryse.com/api/web/Core.Annotations.Annotation.html#getCustomData__anchor

For when the “Apply” button is pressed, you can listen for the “formFieldCreationModeEnded” event like the following

annotationManager.getFormFieldCreationManager().addEventListener('formFieldCreationModeEnded', () => {
 // this will be for when the "Apply" button is pressed
});

Please let me know if the above helps

Best Regards,

Andrew Yip
Web Developer
Apryse

1 Like

Thank you !
How can I be notified for the bug fix ? (to remove my code)

1 Like

Hello,

I can update you in this thread when this get fixed. Also we will mention the fix in our change logs when it get fixed

We don’t have a timeline for when this will be fixed but have added it to our backlog for our product team to review.

Best Regards,

Andrew Yip
Web Developer
Apryse

1 Like

Hi @n.alcina,

Just wanted to let you know this issue has been fixed and is part of our 10.3 release. Let me know if you have any further questions.
Best Regards,

Armando D
Software Developer
Apryse

2 Likes

Hello,
I just update to 10.3
Thank you

1 Like