sillsdev / web-languageforge

Language Forge: Online Collaborative Dictionary Building on the Web and Phone.
https://languageforge.org
MIT License
44 stars 29 forks source link

Entry updates can cause what you're looking at to scroll out of view #1056

Open rmunn opened 3 years ago

rmunn commented 3 years ago

Scenario: person A is looking at an entry that has data in the Gloss and Definition fields. Each one has three writing systems. He has the Definition at the top of the screen and is reading it. Meanwhile, person B edits the Gloss field, deleting the data in its writing systems. The Gloss field in this project is configured as "Hidden if Empty", so it vanishes once its contents have been deleted. Person B goes to another entry, which causes the empty gloss to be saved to Mongo. Now person A's poll update timer fires, causing his client to request any updated entries from the database. His client sees that the gloss is empty, so it redraws the entry with the gloss field hidden. However, since his scrollbar is not touched by this operation, that means that the Definition field (which was at the top of the screen) gets moved up to where the Gloss field used to be on the page, so it's now off above the top of his screen and invisible to him until he scrolls up.

It would be nice if, when an entry is repainted because it pulled an update from the server, the repaint code could remember what part of the entry used to be at the top of the user's screen, and scroll to put that part of the entry at the top of the user's screen again after the repaint. (Or as close to it as possible if the top of the screen is not possible, e.g. that was the tail end of the entry).

This is a nice-to-have feature rather than something urgent.

rmunn commented 3 years ago

This is also showing up while working on #1051. When an entry is saved, and then the pollUpdateSuccess callback gets called (every 32 seconds), it receives the modifications to entry back from the Mongo DB and ends up doing this.currentEntry = .... This assigns the newly-modified entry to the currentEntry property which the Angular view is using to display the entry data, and for reasons I haven't figured out yet, it's that specific assignment that causes the editor view to scroll up to the top of the entry all of a sudden.

megahirt commented 3 years ago

Yes, I have seen this occur before and I'm glad you've documented in what circumstances this occurs. I wish I knew how to solve this but I'm coming up short at the moment.

megahirt commented 2 years ago

I'm pretty sure this is still an issue