Fix scrolling to component
This commit is contained in:
parent
d0b2c08a9a
commit
1348fbb917
|
@ -25,14 +25,16 @@
|
|||
export let wide
|
||||
|
||||
let highlightType
|
||||
let domElement
|
||||
|
||||
$: highlightedProp = $builderStore.highlightedSetting
|
||||
$: allBindings = getAllBindings(bindings, componentBindings, nested)
|
||||
$: safeValue = getSafeValue(value, defaultValue, allBindings)
|
||||
$: replaceBindings = val => readableToRuntimeBinding(allBindings, val)
|
||||
|
||||
$: highlightType =
|
||||
highlightedProp?.key === key ? `highlighted-${highlightedProp?.type}` : ""
|
||||
$: isHighlighted = highlightedProp?.key === key
|
||||
|
||||
$: highlightType = isHighlighted ? `highlighted-${highlightedProp?.type}` : ""
|
||||
|
||||
const getAllBindings = (bindings, componentBindings, nested) => {
|
||||
if (!nested) {
|
||||
|
@ -72,9 +74,19 @@
|
|||
? defaultValue
|
||||
: enriched
|
||||
}
|
||||
|
||||
function scrollToElement(element) {
|
||||
element?.scrollIntoView({
|
||||
behavior: "smooth",
|
||||
block: "center",
|
||||
})
|
||||
}
|
||||
|
||||
$: isHighlighted && scrollToElement(domElement)
|
||||
</script>
|
||||
|
||||
<div
|
||||
bind:this={domElement}
|
||||
id={`${key}-prop-control-wrap`}
|
||||
class={`property-control ${highlightType}`}
|
||||
class:wide={!label || labelHidden || wide === true}
|
||||
|
|
|
@ -183,16 +183,6 @@
|
|||
toggleAddComponent()
|
||||
} else if (type === "highlight-setting") {
|
||||
builderStore.highlightSetting(data.setting, "error")
|
||||
|
||||
// Also scroll setting into view
|
||||
const selector = `#${data.setting}-prop-control`
|
||||
const element = document.querySelector(selector)?.parentElement
|
||||
if (element) {
|
||||
element.scrollIntoView({
|
||||
behavior: "smooth",
|
||||
block: "center",
|
||||
})
|
||||
}
|
||||
} else if (type === "eject-block") {
|
||||
const { id, definition } = data
|
||||
await componentStore.handleEjectBlock(id, definition)
|
||||
|
|
|
@ -28,20 +28,10 @@
|
|||
return titleParts.join(" - ")
|
||||
}
|
||||
|
||||
function onErrorClick(error: UIComponentError) {
|
||||
async function onErrorClick(error: UIComponentError) {
|
||||
componentStore.select(error.componentId)
|
||||
if (error.errorType === "setting") {
|
||||
builderStore.highlightSetting(error.key, "error")
|
||||
|
||||
// TODO: dry from AppPreview
|
||||
const selector = `#${error.key}-prop-control`
|
||||
const element = document.querySelector(selector)?.parentElement
|
||||
if (element) {
|
||||
element.scrollIntoView({
|
||||
behavior: "smooth",
|
||||
block: "center",
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue