Skip to content

Commit

Permalink
fix: button options
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinchappell committed Nov 19, 2024
1 parent b572a80 commit 3075f1c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/lib/js/components/columns/column.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ export default class Column extends Component {

// loops through children and refresh their edit panels
refreshFieldPanels = () => {
this.children.forEach(field => field.panels.nav.refresh())
for (const field of this.children) {
field.panels.nav.refresh()
}
}

/**
Expand Down
15 changes: 10 additions & 5 deletions src/lib/js/components/fields/edit-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,23 @@ export default class EditPanel {
const metaId = this.field.data.meta.id
const fieldOptionData = this.field.get('options')
const type = metaId === 'select' ? 'option' : metaId
const newOptionLabel = i18n.get(`newOptionLabel`, { type }) || 'New Option'
const newOptionLabel = i18n.get('newOptionLabel', { type }) || 'New Option'
const itemKey = `options.${this.data.length}`

const optionTemplate = fieldOptionData.length ? cleanObj(fieldOptionData[fieldOptionData.length - 1]) : {}
const itemData = { ...optionTemplate, label: newOptionLabel, value: slugify(newOptionLabel) }

const lastOptionData = fieldOptionData[fieldOptionData.length - 1]
const optionTemplate = fieldOptionData.length ? lastOptionData : {}
const itemData = { ...optionTemplate, label: newOptionLabel }
if (metaId !== 'button') {
itemData.value = slugify(newOptionLabel)
}
const newOption = new EditPanelItem({
key: itemKey,
data: itemData,
field: this.field,
index: this.props.children.length,
})


// debugger
this.editPanelItems.push(newOption)
this.props.appendChild(newOption.dom)
this.field.set(itemKey, itemData)
Expand Down
20 changes: 13 additions & 7 deletions src/lib/js/components/panels.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,12 @@ export default class Panels {
action: {
click: evt => {
const index = indexOfNode(evt.target, evt.target.parentElement)
this.currentPanel = this.panels[index]
const labels = evt.target.parentElement.childNodes
this.nav.refresh(index)
dom.removeClasses(labels, 'active-tab')
evt.target.classList.add('active-tab')
this.nav.groupChange(index)
// this.currentPanel = this.panels[index]
// const labels = this.labels.querySelectorAll('h5')
// this.nav.refresh(index)
// dom.removeClasses(labels, 'active-tab')
// evt.target.classList.add('active-tab')
},
},
content: panel.config.label,
Expand Down Expand Up @@ -233,14 +234,15 @@ export default class Panels {
let lastOffset = { ...offset }

action.groupChange = newIndex => {
this.activePanelIndex = newIndex
const labels = labelWrap.children
dom.removeClasses(siblingGroups, 'active-panel')
dom.removeClasses(labels, 'active-tab')
this.currentPanel = siblingGroups[newIndex]
this.currentPanel.classList.add('active-panel')

labels[newIndex].classList.add('active-tab')


action.setTranslateX(newIndex)
return this.currentPanel
}

Expand All @@ -255,6 +257,8 @@ export default class Panels {
const panelQueue = [getTransition(lastOffset.panel), getTransition(offset.panel)]
const navQueue = [getTransition(lastOffset.nav), getTransition(this.isTabbed ? 0 : offset.nav)]

debugger

if (reset) {
const [panelStart] = panelQueue
const [navStart] = navQueue
Expand All @@ -278,6 +282,7 @@ export default class Panels {
lastOffset = offset
}
}

panelTransition.addEventListener('finish', handleFinish)
}

Expand All @@ -291,6 +296,7 @@ export default class Panels {
this.activePanelIndex = newIndex
action.groupChange(newIndex)
}
// debugger
action.setTranslateX(this.activePanelIndex)
this.resizePanels()
}
Expand Down

0 comments on commit 3075f1c

Please sign in to comment.