Scroll the highlighted element into view

This commit is contained in:
Andrew Kingston 2022-06-14 14:32:17 +01:00
parent 40018e9332
commit 7ec1b02c99
1 changed files with 10 additions and 0 deletions

View File

@ -192,6 +192,16 @@
} }
} else if (type === "highlight-setting") { } else if (type === "highlight-setting") {
store.actions.settings.highlight(data.setting) store.actions.settings.highlight(data.setting)
// Also scroll setting into view
const selector = `[data-cy="${data.setting}-prop-control"`
const element = document.querySelector(selector)?.parentElement
if (element) {
element.scrollIntoView({
behavior: "smooth",
block: "center",
})
}
} else { } else {
console.warn(`Client sent unknown event type: ${type}`) console.warn(`Client sent unknown event type: ${type}`)
} }