Autocomplete helper: fix scrolling to start

This commit is contained in:
morethanwords 2021-05-25 14:15:43 +03:00
parent 4908fff723
commit ce033077f7
2 changed files with 16 additions and 8 deletions

View File

@ -21,10 +21,20 @@ export default class EmojiHelper extends AutocompleteHelper {
this.container.append(this.list);
this.scrollable = new ScrollableX(this.container);
this.addEventListener('visible', () => {
setTimeout(() => { // it is not rendered yet
this.scrollable.container.scrollLeft = 0;
}, 0);
});
}
public renderEmojis(emojis: string[]) {
if(this.init) {
if(!emojis.length) {
return;
}
this.init();
this.init = null;
}
@ -36,10 +46,6 @@ export default class EmojiHelper extends AutocompleteHelper {
});
}
if(!this.hidden) {
this.scrollable.container.scrollLeft = 0;
}
this.toggle(!emojis.length);
}
}

View File

@ -25,6 +25,12 @@ export default class StickersHelper extends AutocompleteHelper {
}, 'ArrowUp');
this.container.classList.add('stickers-helper');
this.addEventListener('visible', () => {
setTimeout(() => { // it is not rendered yet
this.scrollable.container.scrollTop = 0;
}, 0);
});
}
public checkEmoticon(emoticon: string) {
@ -75,10 +81,6 @@ export default class StickersHelper extends AutocompleteHelper {
}
ready.then(() => {
if(!this.hidden) {
this.scrollable.container.scrollTop = 0;
}
this.list.replaceWith(container);
this.list = container;