Use scrollintoView after using shortcut navigation for finding a next/previous mistake #4

This commit is contained in:
Aljaž Grilc 2025-06-05 08:11:42 +02:00
parent 1163b3c47e
commit 04cd5f2e7d

View File

@ -336,8 +336,6 @@ class BesService {
* @param {Event} e
*/
onShortcutNavigation(e) {
//TODO: If no highlightElement is selected? find the first mistake that comes after cursor and move to it.
if (!this.highlightElements.length) return
switch (e.code) {
case 'BracketLeft':
if (e.ctrlKey) {
@ -1195,7 +1193,9 @@ class BesService {
this.activeMatchIndex = next
const { el, match } = this.sortedMatches[next]
// TODO: find out why scrollintoview does not work well
// Not the cleanest solution, but it is good enough for now
el.scrollIntoView({ behavior: 'instant' })
setTimeout(() => {
this.dismissPopup()
const popup = document.querySelector('bes-popup-el')
BesPopup.clearReplacements()
@ -1205,6 +1205,7 @@ class BesService {
const clientY = `${el.y + 150}`
popup.show(el.x, clientY, this)
})
}, 150)
}
/**