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

Issue when DOM gets modified / restored #17

Closed
srinisubramanian opened this issue Feb 19, 2021 · 4 comments
Closed

Issue when DOM gets modified / restored #17

srinisubramanian opened this issue Feb 19, 2021 · 4 comments

Comments

@srinisubramanian
Copy link

srinisubramanian commented Feb 19, 2021

The page to which we are trying to integrate recogito-js has content organized in tabs. When the page loads the first time and some comments are loaded and the annotations are displayed properly. The recogito-js is initialised by attaching to the main div for this.

Subsequently let's assume user navigates to a different tab and back to tab 1, no annotations are shown. I guess this is due to the fact that the components annotated were destroyed when the tab navigation happened and restored when the tab was recreated. For testing, I added code to reload the comments when the tab 1 is recreated and shown. Now the annotation is shown but not all annotations are shown and its not shown in the right place.

Any idea about this? In general how to reload comments/annotations in case the DOM tree has changed?

@srinisubramanian
Copy link
Author

srinisubramanian commented Feb 19, 2021

My Bad: This is NOT an issue with recogito-js.

What I realized is that due to the DOM modification and restoration, the text coordinates have changed (addition of spaces and new line characters). Unfortunately I do not have control over this. Is it possible to determine annotations without using
the TextPositionSelector with offset/length?

@rsimon
Copy link
Member

rsimon commented Feb 19, 2021

Hi @srinisubramanian,

hm, yes. Dynamic changes to the DOM is something that RecogitoJS may not be very good at. Do you mean the same text might differ on re-render? I don't think there's a way to handle this. At least RecogitoJS will always base the selection on the text offset.

Perhaps there's a way to keep the situation more stable between re-renders by using pre-formatted text? (Either by packing it into a <pre> tag, or by applying a white-space: pre; style. In this case, trying the two different mode settings that RecogitoJS provides might help:

https://github.com/recogito/recogito-js/wiki/API-Reference#initializing-recogitojs

@srinisubramanian
Copy link
Author

Hi @rsimon will try the pre mode and let you know

@srinisubramanian
Copy link
Author

srinisubramanian commented Feb 19, 2021

pre is not an option as formatting is messed up.

Will have to try a different solution so the text does not change.

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

No branches or pull requests

2 participants