From 54901d4ced318d824d343e5c0278ff34305a28a3 Mon Sep 17 00:00:00 2001 From: Ng Guoyou Date: Sun, 5 Aug 2018 22:44:30 +0800 Subject: [PATCH] Fix submenu items having duplicate IDs --- src/menu.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/menu.js b/src/menu.js index a6e1e8b..7ad86b7 100644 --- a/src/menu.js +++ b/src/menu.js @@ -213,12 +213,13 @@ const Menus = { // 2. Parse comments // 3. Parse depth // 4. Construct menu items - pathsArray.forEach(dir => { + pathsArray.forEach((dir, i) => { // HACK if (dir === SPECIAL_DIRS.SEPARATOR) { Menus.makeSeparator(contexts); } else { const parsed = Menus.parsePath(dir); + const { comment, depth, meta, validation, parsedDir } = parsed; if (!validation.valid) { @@ -237,7 +238,9 @@ const Menus = { } else { menuItemCounter[depth] = 1; } - const id = `save-in-${menuItemCounter[depth]}-${comment}-${parsedDir}`; + const id = `save-in-${menuItemCounter[ + depth + ]}-${`${i}${comment}`}-${parsedDir}`; let parentId; if (depth === 0) {