1
0
Fork 0
mirror of synced 2024-07-08 15:56:23 +12:00

Fix click on navigation not selecting it

This commit is contained in:
Andrew Kingston 2023-08-23 15:37:13 +01:00
parent 80e622d2e0
commit 0ef0e58e5e
4 changed files with 16 additions and 12 deletions

View file

@ -999,14 +999,18 @@ export const getFrontendStore = () => {
const parent = findComponentParent(screen.props, componentId) const parent = findComponentParent(screen.props, componentId)
const index = parent?._children.findIndex(x => x._id === componentId) const index = parent?._children.findIndex(x => x._id === componentId)
if (componentId === "screen") { // Check for screen and navigation component edge cases
const screenComponentId = `${screen._id}-screen`
const navComponentId = `${screen._id}-navigation`
console.log(componentId, screenComponentId, navComponentId)
if (componentId === screenComponentId) {
return null return null
} }
if (componentId === "navigation") { if (componentId === navComponentId) {
return "screen" return screenComponentId
} }
if (parent._id === screen.props._id && index === 0) { if (parent._id === screen.props._id && index === 0) {
return "navigation" return navComponentId
} }
// If we have siblings above us, choose the sibling or a descendant // If we have siblings above us, choose the sibling or a descendant
@ -1036,8 +1040,11 @@ export const getFrontendStore = () => {
const parent = findComponentParent(screen.props, componentId) const parent = findComponentParent(screen.props, componentId)
const index = parent?._children.findIndex(x => x._id === componentId) const index = parent?._children.findIndex(x => x._id === componentId)
if (state.selectedComponentId === "screen") { // Check for screen and navigation component edge cases
return "navigation" const screenComponentId = `${screen._id}-screen`
const navComponentId = `${screen._id}-navigation`
if (state.selectedComponentId === screenComponentId) {
return navComponentId
} }
// If we have children, select first child // If we have children, select first child
@ -1076,6 +1083,7 @@ export const getFrontendStore = () => {
} }
}, },
selectPrevious: () => { selectPrevious: () => {
console.log("prev")
const previousId = store.actions.components.getPrevious() const previousId = store.actions.components.getPrevious()
if (previousId) { if (previousId) {
store.update(state => { store.update(state => {
@ -1085,6 +1093,7 @@ export const getFrontendStore = () => {
} }
}, },
selectNext: () => { selectNext: () => {
console.log("next")
const nextId = store.actions.components.getNext() const nextId = store.actions.components.getNext()
if (nextId) { if (nextId) {
store.update(state => { store.update(state => {

View file

@ -156,8 +156,6 @@
store.actions.components.copy(source, true, false) store.actions.components.copy(source, true, false)
await store.actions.components.paste(destination, data.mode) await store.actions.components.paste(destination, data.mode)
} }
} else if (type === "click-nav") {
$store.selectedComponentId = "navigation"
} else if (type === "request-add-component") { } else if (type === "request-add-component") {
toggleAddComponent() toggleAddComponent()
} else if (type === "highlight-setting") { } else if (type === "highlight-setting") {

View file

@ -176,7 +176,7 @@
class:hidden={$routeStore.queryParams?.peek} class:hidden={$routeStore.queryParams?.peek}
class:clickable={$builderStore.inBuilder} class:clickable={$builderStore.inBuilder}
on:click={$builderStore.inBuilder on:click={$builderStore.inBuilder
? builderStore.actions.clickNav ? builderStore.actions.selectComponent(navigationId)
: null} : null}
style={navStyle} style={navStyle}
> >

View file

@ -80,9 +80,6 @@ const createBuilderStore = () => {
} }
store.update(state => ({ ...state, editMode: enabled })) store.update(state => ({ ...state, editMode: enabled }))
}, },
clickNav: () => {
eventStore.actions.dispatchEvent("click-nav")
},
requestAddComponent: () => { requestAddComponent: () => {
eventStore.actions.dispatchEvent("request-add-component") eventStore.actions.dispatchEvent("request-add-component")
}, },