Skip to content

Commit 3075f1c

Browse files
committed
fix: button options
1 parent b572a80 commit 3075f1c

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

src/lib/js/components/columns/column.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ export default class Column extends Component {
108108

109109
// loops through children and refresh their edit panels
110110
refreshFieldPanels = () => {
111-
this.children.forEach(field => field.panels.nav.refresh())
111+
for (const field of this.children) {
112+
field.panels.nav.refresh()
113+
}
112114
}
113115

114116
/**

src/lib/js/components/fields/edit-panel.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,23 @@ export default class EditPanel {
161161
const metaId = this.field.data.meta.id
162162
const fieldOptionData = this.field.get('options')
163163
const type = metaId === 'select' ? 'option' : metaId
164-
const newOptionLabel = i18n.get(`newOptionLabel`, { type }) || 'New Option'
164+
const newOptionLabel = i18n.get('newOptionLabel', { type }) || 'New Option'
165165
const itemKey = `options.${this.data.length}`
166-
167-
const optionTemplate = fieldOptionData.length ? cleanObj(fieldOptionData[fieldOptionData.length - 1]) : {}
168-
const itemData = { ...optionTemplate, label: newOptionLabel, value: slugify(newOptionLabel) }
166+
167+
const lastOptionData = fieldOptionData[fieldOptionData.length - 1]
168+
const optionTemplate = fieldOptionData.length ? lastOptionData : {}
169+
const itemData = { ...optionTemplate, label: newOptionLabel }
170+
if (metaId !== 'button') {
171+
itemData.value = slugify(newOptionLabel)
172+
}
169173
const newOption = new EditPanelItem({
170174
key: itemKey,
171175
data: itemData,
172176
field: this.field,
173177
index: this.props.children.length,
174178
})
175-
179+
180+
// debugger
176181
this.editPanelItems.push(newOption)
177182
this.props.appendChild(newOption.dom)
178183
this.field.set(itemKey, itemData)

src/lib/js/components/panels.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,12 @@ export default class Panels {
142142
action: {
143143
click: evt => {
144144
const index = indexOfNode(evt.target, evt.target.parentElement)
145-
this.currentPanel = this.panels[index]
146-
const labels = evt.target.parentElement.childNodes
147-
this.nav.refresh(index)
148-
dom.removeClasses(labels, 'active-tab')
149-
evt.target.classList.add('active-tab')
145+
this.nav.groupChange(index)
146+
// this.currentPanel = this.panels[index]
147+
// const labels = this.labels.querySelectorAll('h5')
148+
// this.nav.refresh(index)
149+
// dom.removeClasses(labels, 'active-tab')
150+
// evt.target.classList.add('active-tab')
150151
},
151152
},
152153
content: panel.config.label,
@@ -233,14 +234,15 @@ export default class Panels {
233234
let lastOffset = { ...offset }
234235

235236
action.groupChange = newIndex => {
237+
this.activePanelIndex = newIndex
236238
const labels = labelWrap.children
237239
dom.removeClasses(siblingGroups, 'active-panel')
238240
dom.removeClasses(labels, 'active-tab')
239241
this.currentPanel = siblingGroups[newIndex]
240242
this.currentPanel.classList.add('active-panel')
241-
242243
labels[newIndex].classList.add('active-tab')
243-
244+
245+
action.setTranslateX(newIndex)
244246
return this.currentPanel
245247
}
246248

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

260+
debugger
261+
258262
if (reset) {
259263
const [panelStart] = panelQueue
260264
const [navStart] = navQueue
@@ -278,6 +282,7 @@ export default class Panels {
278282
lastOffset = offset
279283
}
280284
}
285+
281286
panelTransition.addEventListener('finish', handleFinish)
282287
}
283288

@@ -291,6 +296,7 @@ export default class Panels {
291296
this.activePanelIndex = newIndex
292297
action.groupChange(newIndex)
293298
}
299+
// debugger
294300
action.setTranslateX(this.activePanelIndex)
295301
this.resizePanels()
296302
}

0 commit comments

Comments
 (0)