Improve new component DND for both types of layout

This commit is contained in:
Andrew Kingston 2024-09-05 14:03:03 +01:00
parent 64f0671f36
commit 5e98580b60
No known key found for this signature in database
3 changed files with 5 additions and 3 deletions

View File

@ -153,7 +153,7 @@
$: builderInteractive =
$builderStore.inBuilder && insideScreenslot && !isBlock && !instance.static
$: devToolsInteractive = $devToolsStore.allowSelection && !isBlock
$: interactive = !isRoot && (builderInteractive || devToolsInteractive)
$: interactive = builderInteractive || devToolsInteractive
$: editing = editable && selected && $builderStore.editMode
$: draggable =
!inDragPath &&
@ -231,6 +231,7 @@
empty: emptyState,
selected,
interactive,
isRoot,
draggable,
editable,
isBlock,
@ -672,6 +673,7 @@
class:parent={hasChildren}
class:block={isBlock}
class:error={errorState}
class:root={isRoot}
data-id={id}
data-name={name}
data-icon={icon}

View File

@ -19,7 +19,7 @@
newId = e.target.dataset.id
} else {
// Handle normal components
const element = e.target.closest(".interactive.component")
const element = e.target.closest(".interactive.component:not(.root)")
newId = element?.dataset?.id
}

View File

@ -93,7 +93,7 @@ export const styleable = (node, styles = {}) => {
node.addEventListener("mouseout", applyNormalStyles)
// Add builder preview click listener
if (newStyles.interactive) {
if (newStyles.interactive && !newStyles.isRoot) {
node.addEventListener("click", selectComponent, false)
node.addEventListener("dblclick", editComponent, false)
}