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 * @param {Event} e
*/ */
onShortcutNavigation(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) { switch (e.code) {
case 'BracketLeft': case 'BracketLeft':
if (e.ctrlKey) { if (e.ctrlKey) {
@ -1195,16 +1193,19 @@ class BesService {
this.activeMatchIndex = next this.activeMatchIndex = next
const { el, match } = this.sortedMatches[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
this.dismissPopup() el.scrollIntoView({ behavior: 'instant' })
const popup = document.querySelector('bes-popup-el') setTimeout(() => {
BesPopup.clearReplacements() this.dismissPopup()
popup.setContent(el, match, this, this.isContentEditable()) const popup = document.querySelector('bes-popup-el')
this.highlightMistake(match) BesPopup.clearReplacements()
match.highlights.forEach(el => { popup.setContent(el, match, this, this.isContentEditable())
const clientY = `${el.y + 150}` this.highlightMistake(match)
popup.show(el.x, clientY, this) match.highlights.forEach(el => {
}) const clientY = `${el.y + 150}`
popup.show(el.x, clientY, this)
})
}, 150)
} }
/** /**