diff --git a/src/EditView.js b/src/EditView.js index 693ba6c..8041c51 100644 --- a/src/EditView.js +++ b/src/EditView.js @@ -211,13 +211,15 @@ export default class EditView extends React.Component { onMenuNew(type, group) { // create a new item based on the currently selected one. - // state.content holds the current item. + // state.content holds the current item. Might be null for coremaps. const base = capitalize(type) !== this.state.path[0] ? TEMPLATES[type] - : this.state.content; + : this.state.content || TEMPLATES[type]; const newItem = EDITORS[capitalize(type)].createNew(base); newItem.group = group; + // need to override ID for coremaps so they are selectable in the menu + if (type === 'coremaps') newItem.id = `${newItem.group}-1`; if (newItem.label !== undefined) { newItem.label = uniqueLabel(newItem.label, this.state[type]); if (newItem.labelToUse !== undefined) { @@ -434,7 +436,7 @@ export default class EditView extends React.Component { const coremap = newState.core[info.coremap]; if (coremap) { const newMap = { - id: `coremap-${info.group}`, + id: `${info.group}-1`, type: 'coremaps', label: info.label, cell_map: coremap, @@ -559,30 +561,25 @@ export default class EditView extends React.Component { const coremaps = this.state.coremaps.filter( (a) => a.group === info.group ); + // menu item key must match ID of the single coremap per type. return ( - this.onMenuNew('coremaps', info.group) - } - /> - } - > - {coremaps.map((a) => ( - - - - {a.labelToUse || a.label} - - - ))} - + + + + {`${info.label} Map`} + + {coremaps.length === 0 && ( +