Skip to content

Commit 9026c4b

Browse files
author
billy clark
authored
Release 1.11.1
2 parents c24a72b + 584f7fa commit 9026c4b

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

src/angular-app/languageforge/lexicon/editor/editor.component.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,13 +1219,7 @@ export class LexiconEditorController implements angular.IController {
12191219
}
12201220

12211221
private scrollListToEntry(id: string, alignment: string = 'center'): void {
1222-
const entryDivId = '#entryId_' + id;
1223-
const listDivId = '#compactEntryListContainer';
12241222
let index = this.editorService.getIndexInList(id, this.filteredEntries);
1225-
1226-
// make sure the item is visible in the list
1227-
// todo implement lazy "up" scrolling to make this more efficient
1228-
12291223
// only expand the "show window" if we know that the entry is actually in
12301224
// the entry list - a safe guard
12311225
if (index != null) {
@@ -1239,18 +1233,16 @@ export class LexiconEditorController implements angular.IController {
12391233
}
12401234
}
12411235

1242-
// note: ':visible' is a JQuery invention that means 'it takes up space on
1243-
// the page'.
1244-
// It may actually not be visible at the moment because it may down inside a
1245-
// scrolling div or scrolled off the view of the page
1246-
if ($(listDivId).is(':visible') && $(entryDivId).is(':visible')) {
1247-
LexiconEditorController.syncListEntryWithCurrentEntry(entryDivId, alignment)
1248-
} else {
1249-
// wait then try to scroll
1250-
this.$interval(() => {
1236+
// there's a fundamental problem in this code related to synchronization and the interval is a hack to deal with it until the correct solution is found.
1237+
// Ideally, we would only want to try and find this entry once the list is rendered, possibly on a lifecycle hook like mounted or something, or possibly
1238+
// asynchronously upon data retrieval...I'm not exactly sure what's needed here, but this is a poor-man's start.
1239+
const entryDivId = '#entryId_' + id;
1240+
const interval = this.$interval(() => {
1241+
if ($(entryDivId)[0]) {
12511242
LexiconEditorController.syncListEntryWithCurrentEntry(entryDivId, alignment)
1252-
}, 200, 1);
1253-
}
1243+
this.$interval.cancel(interval)
1244+
}
1245+
}, 200, 30); // 200ms delay, 30 tries max
12541246
}
12551247

12561248
private static syncListEntryWithCurrentEntry(elementId: string, alignment: string = 'center'): void {

0 commit comments

Comments
 (0)