This commit is contained in:
Adria Navarro 2025-02-17 19:48:15 +01:00
parent 8018f5f25b
commit 69e1ae0aec
2 changed files with 6 additions and 6 deletions

View File

@ -85,7 +85,7 @@ export const findComponentPath = (
* a certain selector
*/
export const findAllMatchingComponents = (
rootComponent: Component,
rootComponent: Component | null,
selector: (component: Component) => boolean
) => {
if (!rootComponent || !selector) {

View File

@ -485,7 +485,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
(component: Component) => component._component.endsWith("/form")
)
const formSteps = findAllMatchingComponents(
parentForm!,
parentForm,
(component: Component) => component._component.endsWith("/formstep")
)
extras.step = formSteps.length + 1
@ -644,7 +644,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
nextId = nextId.replace("-navigation", "-screen")
}
this.update(state => {
state.selectedComponentId = nextId!
state.selectedComponentId = nextId ?? undefined
return state
})
}
@ -704,7 +704,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
}
async paste(
targetComponent: Component | null,
targetComponent: Component,
mode: string,
targetScreen: Screen,
selectComponent = true
@ -727,7 +727,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
// Patch screen
const patch = (screen: Screen) => {
// Get up to date ref to target
targetComponent = findComponent(screen.props, targetComponent!._id!)
targetComponent = findComponent(screen.props, targetComponent!._id!)!
if (!targetComponent) {
return false
}
@ -789,7 +789,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
}
const targetIndex = parent._children.findIndex(
(component: Component) => {
return component._id === targetComponent!._id
return component._id === targetComponent._id
}
)
const index = mode === "above" ? targetIndex : targetIndex + 1